Вход Регистрация
Файл: IPBMafia.ru_IPB_3.4.6_Final_Rus _Nulled/board/upload/admin/applications/core/js/ipb3Templates.js
Строк: 358
<?php
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/

/**
* "ACP" Class. Designed for ... ACP Templating Functions
* @author (v.1.0.0) Matt Mecham
*/

function IPBTemplates()
{
    
/**
    * Template groups
    *
    * @var    array
    */
    
this.templateGroups = {};
    
    
/**
    * Current template group
    *
    * @var    array
    */
    
this.currentTemplateGroup '';
    
    
/**
    * Current template bit
    *
    * @var    array
    */
    
this.currentTemplateBit '';
    
    
/**
    * Current set ID
    *
    * @var    array
    */
    
this.currentSetData = {};
    
    
/**
    * CSS Names
    *
    * @var hash
    */
    
this.cssNames = { 'groupRowLit'     'tplateLit',
                      
'groupHover'      'groupHover',
                      
'groupRowLitMain' 'row1',
                      
'groupRow'        'row2',
                      
'templateRow'     'row2',
                      
'templateHover'   'templateHover' };
    
    
    
/**
    * INIT Applications
    */
    
this.init = function()
    {
        
/* Build group list */
        
this.buildGroupsList();
        
        
/* fix template window to same height as group list and make it scrollable */
        
$('tplate_bitList').setStyle( { 'height' : $('tplate_groupList').getHeight() + 'px''overflow' 'auto'} );
    
        
this.loadTemplateBitsthis.currentTemplateGroup );
    };
    
    
/**
    * Load template groups
    */
    
this.loadTemplateGroups = function()
    {
        
/* Grab the JSON for the template bits for the current template group */
        
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateGroupList&amp;setID=" this.currentSetData['set_id'] + '&secure_key=' ipb.vars['md5_hash'];
    
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                          {
                            
method'GET',
                            
onSuccess: function ()
                            {
                                if ( 
t.responseText.match( /^(s+?)?{/ ) )
                                {
                                    $(
'tplate_debug').innerHTML += "n" t.responseText;
                                    
                                    eval( 
"var json = " t.responseText );
                                    
                                    if ( 
json['error'] )
                                    {
                                        
alertjson['error'] );
                                        return;
                                    }
                                    else
                                    {
                                        
IPB3Templates.templateGroups json;
                                        
IPB3Templates.buildGroupsList();
                                        
                                        
/* Hilite */
                                        
IPB3Templates.hiliteGroupIPB3Templates.currentTemplateGroup );
                                    }
                                }
                                else
                                {
                                    
alert"Ooops. Something went wrong. Does this help?: " t.responseText );
                                }
                            },
                            
onException: function( f,){ alert"Exception: " ); },
                            
onFailure: function( ){ alert"Failure: " t.responseText ); }
                          } );
    };
    
    
/**
    * Load template bits
    */
    
this.loadTemplateBits = function( groupNameforce )
    {        
        
/* Grab the JSON for the template bits for the current template group */
        
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateBitList&amp;setID=" this.currentSetData['set_id'] + '&templateGroup=' groupName '&secure_key=' ipb.vars['md5_hash'];
    
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                          {
                            
method'GET',
                            
onSuccess: function ()
                            {
                                if ( 
t.responseText.match( /^(s+?)?{/ ) )
                                {
                                    $(
'tplate_debug').innerHTML += "n" t.responseText;
                                    
                                    eval( 
"var json = " t.responseText );
                                    
                                    if ( 
json['error'] )
                                    {
                                        
alertjson['error'] );
                                        return;
                                    }
                                    else
                                    {
                                        var 
_reload 0;
                                        
                                        
/* New group? */
                                        
if ( ! IPB3Templates.templateGroups['groups'][ groupName ] )
                                        {
                                            
IPB3Templates.templateGroups['groups'][ groupName ] = { '_modCount' 0'template_group' groupName };
                                            
_reload 1;
                                        }
                                        
                                        
/* Update group's template count */
                                        
if ( json['groupData'] )
                                        {
                                            if ( 
json['groupData']['_modCount'] != IPB3Templates.templateGroups['groups'][ groupName ]['_modCount'] )
                                            {
                                                
IPB3Templates.templateGroups['groups'][ groupName ]['_modCount'] = json['groupData']['_modCount'];
                                                
_reload 1;
                                            }
                                        }
                                        
                                        
/* Re-draw list */
                                        
if ( _reload )
                                        {
                                            
IPB3Templates.buildGroupsList();
                                        }
                                        
                                        
/* Hilite */
                                        
IPB3Templates.hiliteGroupgroupName );
                                        
IPB3Templates.buildTemplateListjson );
                                    }
                                }
                                else
                                {
                                    
alert"Ooops. Something went wrong. Does this help?: " t.responseText );
                                }
                            },
                            
onException: function( f,){ alert"Exception: " ); },
                            
onFailure: function( ){ alert"Failure: " t.responseText ); }
                          } );
    };
    
    
/**
    * Save template bit
    */
    
this.saveTemplateBit = function( template_id )
    {
        
/* Grab the JSON for the template bits for the current template group */
        
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=saveTemplateBit&amp;setID=" this.currentSetData['set_id'] + '&template_id=' template_id '&secure_key=' ipb.vars['md5_hash'];
        
        
/* Set up params */
        
var params = { 'template_content' $F('tplate_editBox_' template_id ),
                       
'template_data'    $F('tplate_dataBox_' template_id ),
                       
'template_set'     this.currentSetData['set_id'],
                       
'template_group'   IPB3Templates.currentTemplateGroup,
                       
'type'             IPB3Templates.currentTemplateBit['_type'] };
                
        if ( 
IPB3Templates.currentTemplateBit['_type'] == 'add' )
        {
            
params['_template_name']  = $F('tplate_addNameTextField_0');
            
params['_template_group'] = $F('tplate_addGroupTextField_0');
        }
        
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                          {
                            
method'POST',
                            
parametersparams,
                            
onSuccess: function ()
                            {
                                if ( 
t.responseText.match( /^(s+?)?{/ ) )
                                {
                                    eval( 
"var json = " t.responseText );
                                    
                                    if ( 
json['error'] )
                                    {
                                        
alertjson['error'] );
                                        return;
                                    }
                                    else
                                    {
                                        
IPB3Templates.currentTemplateBit json['templateData'];
                                        
IPB3Templates.showTemplateEditorjson );
                                        
IPB3Templates.loadTemplateBitsjson['templateData']['template_group'] );
                                        
                                        if ( 
json['errors'] )
                                        {
                                            
/* Something inline would be very nice here.. rather than this ugly alert */
                                            
alert("Error:: " json['errors'] );
                                        }
                                        else
                                        {
                                            
alert("Error:: Saved!");
                                        }
                                    }
                                }
                                else
                                {
                                    
alert"Ooops. Something went wrong. Does this help?: " t.responseText );
                                }
                            },
                            
onException: function( f,){ alert"Exception: " ); },
                            
onFailure: function( ){ alert"Failure: " t.responseText ); }
                          } );
    };
    
    
/**
    * Revert template bit
    */
    
this.revertTemplateBit = function( template_id )
    {
        
/* Make sure we're mean it... */
        
if ( $('tplate_templaterow_' template_id ).hasClassName'tplateRow_new')  )
        {
            if ( ! 
confirm"Удалить шаблон?n Произойдет удаление шаблона из ВСЕХ стилей!" ) )
            {
                return 
false;
            }
        }
        else
        {
            if ( ! 
confirm"Отменить изменения?n Все изменения БУДУТ УТРАЧЕНЫ!" ) )
            {
                return 
false;
            }
        }
        
        
/* Grab the JSON for the template bits for the current template group */
        
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=revertTemplateBit&amp;setID=" this.currentSetData['set_id'] + '&template_id=' template_id '&secure_key=' ipb.vars['md5_hash'];
    
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                          {
                            
method'GET',
                            
onSuccess: function ()
                            {
                                if ( 
t.responseText.match( /^(s+?)?{/ ) )
                                {
                                    eval( 
"var json = " t.responseText );
                                    
                                    if ( 
json['error'] )
                                    {
                                        
alertjson['error'] );
                                        return;
                                    }
                                    else
                                    {
                                        if ( 
json['templateData'] )
                                        {
                                            
IPB3Templates.currentTemplateBit json['templateData'];
                                        }
                                        else
                                        {
                                            
/* Reload the group */
                                            
IPB3Templates.loadTemplateGroups();
                                        }
                                        
                                        
IPB3Templates.loadTemplateBitsIPB3Templates.currentTemplateBit['template_group'] );
                                        
                                        if ( 
json['errors'] )
                                        {
                                            
/* Something inline would be very nice here.. rather than this ugly alert */
                                            
alert("Error:: " json['errors'] );
                                        }
                                    }
                                }
                                else
                                {
                                    
alert"Ooops. Something went wrong. Does this help?: " t.responseText );
                                }
                            },
                            
onException: function( f,){ alert"Exception: " ); },
                            
onFailure: function( ){ alert"Failure: " t.responseText ); }
                          } );
    };
    
    
/**
    * Load template bits
    */
    
this.loadTemplateEditor = function( template_id )
    {
        
/* Grab the JSON for the template bits for the current template group */
        
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateForEdit&amp;setID=" this.currentSetData['set_id'] + '&template_id=' template_id '&secure_key=' ipb.vars['md5_hash'];
    
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                          {
                            
method'GET',
                            
onSuccess: function ()
                            {
                                if ( 
t.responseText.match( /^(s+?)?{/ ) )
                                {
                                    eval( 
"var json = " t.responseText );
                                    
                                    if ( 
json['error'] )
                                    {
                                        
alertjson['error'] );
                                        return;
                                    }
                                    else
                                    {
                                        
IPB3Templates.showTemplateEditorjson );
                                    }
                                }
                                else
                                {
                                    
alert"Ooops. Something went wrong. Does this help?: " t.responseText );
                                }
                            },
                            
onException: function( f,){ alert"Exception: " ); },
                            
onFailure: function( ){ alert"Failure: " t.responseText ); }
                          } );
    };
    
    
/**
    * Shows the new template bit form
    */
    
this.addBitForm = function()
    {
        
/* Close any open editors */
        
IPB3Templates.cancelTemplateBit);
        
        var 
_tplate = new Template( $('tplate_templateEditorAdd').innerHTML );
        var 
_data   = { 'template_id'      0,
                        
'template_set_id'  IPB3Templates.currentSetData['set_id'],
                        
'template_group'   IPB3Templates.currentTemplateGroup,
                        
'template_content' '',
                        
'_type'            'add' };
                                                    
        var 
_div         document.createElement"DIV" );
        
_div.id          'tplate_editorWrapper';
        
_div.update_tplate.evaluate_data ) );
        
document.body.appendChild_div );
        
        
ipb.positionCenter'tplate_editor_0' );
        
        
IPB3Templates.currentTemplateBit _data;
    };
    
    
/**
    * Shows the template editor
    */
    
this.showTemplateEditor = function( json )
    {
        
/* Close any open editors */
        
IPB3Templates.cancelTemplateBitjson['templateData']['template_id'] );
        
        var 
_tplate = new Template( $('tplate_templateEditor').innerHTML );
        
        
IPB3Templates.currentTemplateBit json['templateData'];
        
        var 
_div         document.createElement"DIV" );
        
_div.id          'tplate_editorWrapper';
        
_div.update_tplate.evaluatejson['templateData'] ) );
        
document.body.appendChild_div );
        
        
ipb.positionCenter'tplate_editor_' json['templateData']['template_id'] );
    };
    
    
/**
    * Shows the template editor
    */
    
this.cancelTemplateBit = function( templateID )
    {
        
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
        {
            return false;
        }*/
        
        
try
        {
            $(
'tplate_editorWrapper').remove();
        }
        catch(
e)
        {
        }
    };
    
    
/**
    * Shows a group entry as 'lit'
    */
    
this.hiliteGroup = function( templateGroup )
    {
        
/* Un-hi-lite all groups */
        
var _groups Object.keysIPB3Templates.templateGroups['groups'] ).sort();
        
        
/* Format... */
        
_groups.each( function( )
        {
            
/* Fix up template */
            
$('tplate_grouprow_' ).removeClassNameIPB3Templates.cssNames['groupRowLitMain'] );
            $(
'tplate_grouprow_' ).removeClassNameIPB3Templates.cssNames['groupRowLit'] );
            $(
'tplate_grouprow_' ).addClassNameIPB3Templates.cssNames['groupRow'] );
        } );
        
        $(
'tplate_grouprow_' templateGroup ).removeClassNameIPB3Templates.cssNames['groupRow'] );
        $(
'tplate_grouprow_' templateGroup ).addClassNameIPB3Templates.cssNames['groupRowLitMain'] );
        $(
'tplate_grouprow_' templateGroup ).addClassNameIPB3Templates.cssNames['groupRowLit'] );
    };
    
    
/**
    * Build a list of template groups
    */
    
this.buildGroupsList = function()
    {
        
/* INIT */
        
var _output '';
        var 
_tplate = new Template( $('tplate_groupRow').innerHTML );
        var 
json    IPB3Templates.templateGroups;
        
        var 
_groups Object.keysjson['groups'] ).sort();
        
        
/* Clear out any current listing */
        
$('tplate_groupList').update('');
        
        
/* Format... */
        
_groups.each( function( )
        {
            
_output += _tplate.evaluate( { 'groupName' i'_modCount' json['groups'][i]['_modCount'] } );
        } );
        
        
/* Write it out */
        
$('tplate_groupList').update_output );
    };
    
    
/**
    * Build a list of template bits
    */
    
this.buildTemplateList = function( json )
    {
        
/* INIT */
        
var _output '';
        var 
_tplate = new Template( $('tplate_templateRow').innerHTML );
        
        
/* Clear out any current listing */
        
$('tplate_bitList').update('');
        
        
/* Add in the new... */
        
for( json['templates'].lengthi++ )
        {
            
/* Figure out if this in an inherited row, a changed row, a new row or a default row */
            
if ( json['templates'][i]['template_added_to'] == IPB3Templates.currentSetData['set_id'] )
            {
                
/* This is a modified row */
                
json['templates'][i]['_templateState']  = 'new';
                
json['templates'][i]['_cssClass']       = 'tplateRow_new';
            }
            else if ( 
json['templates'][i]['template_set_id'] == IPB3Templates.currentSetData['set_id'] )
            {
                
/* This is a modified row */
                
json['templates'][i]['_templateState']  = 'modified';
                
json['templates'][i]['_cssClass']       = 'tplateRow_mod';
            }
            else if ( 
IPB3Templates.currentSetData['_parentTree'].indexOfjson['templates'][i]['template_set_id'] ) != -)
            {
                
/* Inherited */
                
json['templates'][i]['_templateState']  = 'inherit';
                
json['templates'][i]['_cssClass']       = 'tplateRow_inh';
            }
            else
            {
                
/* This is a default row */
                
json['templates'][i]['_templateState']  = 'default';
                
json['templates'][i]['_cssClass']       = 'tplateRow_def';
            }
            
            
_output += _tplate.evaluatejson['templates'][i] );
        }
        
        
/* Write it out */
        
$('tplate_bitList').update_output );
        
        
/* Post Process */
        
for( json['templates'].lengthi++ )
        {
            if ( 
json['templates'][i]['_templateState'] == 'new' )
            {
                $(
'tplate_templateRow_' json['templates'][i]['template_id'] + '_revert').update('Remove');
            }
            else if ( 
json['templates'][i]['_templateState'] != 'default' )
            {
                $(
'tplate_templateRow_' json['templates'][i]['template_id'] + '_revert').show();
            }
            else
            {
                $(
'tplate_templateRow_' json['templates'][i]['template_id'] + '_revert').hide();
            }
        }
    };
    
    
/**
    * Template Mouse Event
    */
    
this.templateMouseEvent = function( )
    {
        if ( 
_div = $( Event.element) ).up'.' IPB3Templates.cssNames['templateRow'] ) )
        {
            var 
_template_id _div.id.replace'tplate_templaterow_''' );
            
            if ( 
e.type == 'mouseover' )
            {
                
_div.addClassNameIPB3Templates.cssNames['templateHover'] );
            }
            else if ( 
e.type == 'mouseout' )
            {
                
_div.removeClassNameIPB3Templates.cssNames['templateHover'] );
            }
            else if ( 
e.type == 'click' )
            {
                var 
_el Event.findElemente'div' ).id;
                
                if ( 
_el.endsWith('_revert' ) )
                {
                    
IPB3Templates.revertTemplateBit_template_id );
                }
                else
                {
                    
IPB3Templates.loadTemplateEditor_template_id );
                }
            }
        }
    };
    
    
/**
    * Group Mouse Event
    */
    
this.groupMouseEvent = function( )
    {
        var 
groupName = $( Event.findElemente'div' ) ).id;
        var 
_groupName groupName.replace'tplate_grouprow_''' );
        
        if ( 
e.type == 'mouseover' )
        {
            $( 
groupName ).addClassNameIPB3Templates.cssNames['groupHover'] );
        }
        else if ( 
e.type == 'mouseout' )
        {
            $( 
groupName ).removeClassNameIPB3Templates.cssNames['groupHover'] );
        }
        else if ( 
e.type == 'click' )
        {
            
IPB3Templates.currentTemplateGroup _groupName;
            
            
IPB3Templates.loadTemplateBits_groupName );
        }
    };
}
?>
Онлайн: 0
Реклама