📄 acp_template.js
字号:
// Close template bit window
/*-------------------------------------------------------------------------*/
function template_close_bits()
{
//------------------------------------------
// Resize other div and iframe
//------------------------------------------
div_template_bits.style.width = '0%';
div_template_bits.style.display = 'none';
iframe_template_bits.style.width = '0%';
iframe_template_bits.style.display = 'none';
//------------------------------------------
// Change row color
//------------------------------------------
if ( template_group_loaded )
{
document.getElementById( template_group_loaded ).className = class_before;
}
//------------------------------------------
// Close editor?
//------------------------------------------
if ( template_bit_loaded.length )
{
div_template_edit.style.display = 'none';
iframe_template_edit.src = 'javascript:;';
}
//------------------------------------------
// Do anim
//------------------------------------------
template_section_moved = 0;
template_sections_expand();
}
/*-------------------------------------------------------------------------*/
// Load template bits iframe
/*-------------------------------------------------------------------------*/
function template_add_bit( add_url, event )
{
//------------------------------------------
// INIT
//------------------------------------------
var url_to_load = add_url;
var newheight = 220;
var newpadding = 0;
//------------------------------------------
// Got an event? From a link, then
//------------------------------------------
if ( event )
{
template_cancel_bubble( event, true, window.frames['tb-iframe'] );
}
//------------------------------------------
// Unsaved changes?
//------------------------------------------
if ( editor_unload_set )
{
if ( ! confirm('WARNING: CLICK "OK" TO LOSE ANY UNSAVED CHANGES' ) )
{
return false;
}
}
editor_contents = new Array();
editor_unload_set = 0;
//------------------------------------------
// Resize other div and iframe
//------------------------------------------
div_template_edit.style.width = '100%';
div_template_edit.style.height = newheight + newpadding + 'px';
div_template_edit.style.display = 'block';
iframe_template_edit.style.width = '100%';
iframe_template_edit.style.height = newheight + newpadding + 'px';
iframe_template_edit.scrolling = 'auto';
iframe_template_edit.frameborder = 'no';
iframe_template_edit.style.display = 'block';
//------------------------------------------
// Load bits
//------------------------------------------
iframe_template_edit.src = url_to_load;
}
/*-------------------------------------------------------------------------*/
// Load template bits iframe
/*-------------------------------------------------------------------------*/
function template_load_editor( bit_name, event, bit_url )
{
//------------------------------------------
// INIT
//------------------------------------------
var count = 1;
//------------------------------------------
// Loading from a clicked link
//------------------------------------------
if ( ! bit_url )
{
var bn_object = window.frames['tb-iframe'].document.getElementById( 'bn-'+bit_name );
var url_to_load = bn_object.href;
var newheight = template_edit_mheight;
var newpadding = 0;
}
//------------------------------------------
// Loading from a URL (multiple bits
//------------------------------------------
else
{
var url_to_load = bit_url;
var newheight = template_edit_mheight_mpl;
var newpadding = template_edit_mheight_mpl_pad;
}
//------------------------------------------
// Got an event? From a link, then
//------------------------------------------
if ( event )
{
template_cancel_bubble( event, true, window.frames['tb-iframe'] );
}
//------------------------------------------
// Unsaved changes?
//------------------------------------------
if ( editor_unload_set )
{
if ( ! confirm('WARNING: CLICK "OK" TO LOSE ANY UNSAVED CHANGES' ) )
{
return false;
}
}
editor_contents = new Array();
editor_unload_set = 0;
//------------------------------------------
// Change row color
//------------------------------------------
if ( template_bit_loaded.length )
{
try
{
for ( var i in template_bit_loaded )
{
// Change any coloured rows back
window.frames['tb-iframe'].document.getElementById( template_bit_loaded[i] ).className = class_before;
}
}
catch(e)
{
}
}
//------------------------------------------
// Multiple bits?
//------------------------------------------
if ( bit_url )
{
try
{
for( var i in bits_clicked )
{
count++;
window.frames['tb-iframe'].document.getElementById( 'dvb-'+i ).className = class_after;
template_bit_loaded[ template_bit_loaded.length + 1 ] = 'dvb-'+i;
}
}
catch(e)
{
}
count--;
}
//------------------------------------------
// Single bits
//------------------------------------------
else
{
template_bit_loaded = new Array();
window.frames['tb-iframe'].document.getElementById( 'dvb-'+bit_name ).className = class_after;
template_bit_loaded[ template_bit_loaded.length + 1 ] = 'dvb-'+bit_name;
}
//------------------------------------------
// Resize other div and iframe
//------------------------------------------
div_template_edit.style.width = '100%';
div_template_edit.style.height = newheight * count + newpadding + 'px';
div_template_edit.style.display = 'block';
iframe_template_edit.style.width = '100%';
iframe_template_edit.style.height = newheight * count + newpadding + 'px';
iframe_template_edit.scrolling = 'auto';
iframe_template_edit.frameborder = 'no';
iframe_template_edit.style.display = 'block';
//------------------------------------------
// Load bits
//------------------------------------------
iframe_template_edit.src = url_to_load;
//------------------------------------------
// Scroll up..
//------------------------------------------
var _reach_the_stars = _get_obj_toppos( div_template_edit );
if ( _reach_the_stars )
{
scroll( 0, _reach_the_stars );
}
}
/*-------------------------------------------------------------------------*/
// Load template bits iframe
/*-------------------------------------------------------------------------*/
function template_load_bits( group_name, event, nocancel )
{
//------------------------------------------
// INIT
//------------------------------------------
var gn_object = document.getElementById( 'gn-'+group_name );
var url_to_load = gn_object.href;
//------------------------------------------
// Don't cancel if we're reloading
//------------------------------------------
if ( nocancel != true )
{
template_cancel_bubble( event, true );
}
//------------------------------------------
// Change row color
//------------------------------------------
if ( template_group_loaded )
{
// Change any coloured rows back
document.getElementById( template_group_loaded ).className = class_before;
template_cancel_bubble( event, true );
}
document.getElementById( 'dv-'+group_name ).className = class_after;
template_group_loaded = 'dv-'+group_name;
//------------------------------------------
// Do anim
//------------------------------------------
if ( ! template_section_moved )
{
template_section_moved = 1;
template_sections_contract();
}
//------------------------------------------
// Resize other div and iframe
//------------------------------------------
div_template_bits.style.width = 100 - template_section_fwidth + '%';
div_template_bits.style.height = main_height + 'px';
div_template_bits.style.display = '';
//------------------------------------------
// Load bits
//------------------------------------------
iframe_template_bits.src = url_to_load;
iframe_template_bits.style.height = main_height + 'px';
iframe_template_bits.scrolling = 'auto';
iframe_template_bits.frameborder = 'no';
iframe_template_bits.style.display = '';
iframe_template_bits.style.width = '100%';
}
/*-------------------------------------------------------------------------*/
// Anim: Move section to the left
/*-------------------------------------------------------------------------*/
function template_sections_contract()
{
var width = parseInt( div_template_sections.style.width ) ? parseInt( div_template_sections.style.width ) : 100;
var new_width = width - 10;
clearTimeout( template_section_anim );
if ( new_width < template_section_fwidth )
{
new_width = template_section_fwidth;
}
div_template_sections.style.width = new_width + '%';
//------------------------------------------
// Still got some more to go?
//------------------------------------------
if ( new_width > template_section_fwidth )
{
template_anim_done = 0;
template_section_anim = setTimeout( 'template_sections_contract()', 5 );
}
else
{
template_anim_done = 1;
bits_clicked = new Array();
}
}
/*-------------------------------------------------------------------------*/
// Anim: Move section to the left
/*-------------------------------------------------------------------------*/
function template_sections_expand()
{
var width = parseInt( div_template_sections.style.width ) ? parseInt( div_template_sections.style.width ) : template_section_fwidth;
var new_width = width + 10;
clearTimeout( template_section_anim );
if ( new_width > 100 )
{
new_width = 100;
}
div_template_sections.style.width = new_width + '%';
//------------------------------------------
// Still got some more to go?
//------------------------------------------
if ( new_width < 100 )
{
template_section_anim = setTimeout( 'template_sections_expand()', 5 );
}
}
/*-------------------------------------------------------------------------*/
// Prevent browser bubblin'
/*-------------------------------------------------------------------------*/
function template_cancel_bubble(obj, extra, wobj)
{
if ( ! obj || is_ie)
{
if ( ! wobj )
{
wobj = window;
}
try
{
if ( extra )
{
wobj.event.returnValue = false;
}
wobj.event.cancelBubble = true;
return wobj.event;
}
catch(e) { }
}
else
{
obj.stopPropagation();
if ( extra )
{
obj.preventDefault();
}
return obj;
}
}
/*-------------------------------------------------------------------------*/
// Load template bits for editing
/*-------------------------------------------------------------------------*/
function template_load_bits_to_edit( baseurl )
{
var bits = '';
//------------------------------------------
// Build template bits to edit
//------------------------------------------
for ( var i in bits_clicked )
{
if ( (bits_clicked[i] != "") && (bits_clicked[i] != null) && (bits_clicked != 'undefined') )
{
bits += i + '|';
}
}
//------------------------------------------
// Got owt?
//------------------------------------------
if ( ! bits || bits == '' )
{
return false;
}
template_load_editor( null, null, baseurl+'&bitname=' + bits );
}
/*-------------------------------------------------------------------------*/
// Jump handler
/*-------------------------------------------------------------------------*/
function _template_load_editor_loader( event )
{
if ( is_ie )
{
// OMG. Could not get readyState == 4 to work o_O
// "complete" and COMPLETE didn't work either
// So I resorted to this hack. Too tired to see
// what's really up
ie_rs_count++;
if ( ie_rs_count < 3 )
{
return;
}
ie_rs_count = 0;
}
if ( search_template_bit )
{
template_load_editor( search_template_bit, event );
}
}
/*-------------------------------------------------------------------------*/
// Toggle bit row
/*-------------------------------------------------------------------------*/
function template_toggle_bit_row( bit_name )
{
//------------------------------------------
// Already selected?: YES
//------------------------------------------
if ( bits_clicked[ bit_name ] )
{
window.frames['tb-iframe'].document.getElementById( 'dvb-'+bit_name ).className = class_before;
delete( bits_clicked[ bit_name ] );
}
//------------------------------------------
// Already selected?: NO
//------------------------------------------
else
{
window.frames['tb-iframe'].document.getElementById( 'dvb-'+bit_name ).className = class_after;
bits_clicked[ bit_name ] = 1;
}
}
/*-------------------------------------------------------------------------*/
// Change state image
/*-------------------------------------------------------------------------*/
function _template_change_state_image( tid, img )
{
try
{
window.frames['tb-iframe'].document.getElementById( 'img-item-' + tid ).src = document.getElementById( 'img-' + img ).src;
}
catch( e ) { }
}
/*-------------------------------------------------------------------------*/
// Change revert image
/*-------------------------------------------------------------------------*/
function _template_change_revert_image( tid, img )
{
try
{
window.frames['tb-iframe'].document.getElementById( 'img-remove-' + tid ).src = img;
window.frames['tb-iframe'].document.getElementById( 'img-remove-' + tid ).style.width = img == img_revert_blank ? 1 : img_revert_width + 'px';
window.frames['tb-iframe'].document.getElementById( 'img-remove-' + tid ).style.height = img == img_revert_blank ? 1 : img_revert_height + 'px';
}
catch( e ) { }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -