/*
Copyright 2008 Kevin Morey (email : kevin@kmorey.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
var advtag_pluginDir = '';
var advtag_blogHome = '';
var advtag_ajaxUrl = '';
var jQuery = jQuery.noConflict();
var STR_REACTIVATE_TAGLINE = "Re-activate Tagline";
var STR_EDIT_TAGLINE = "Edit Tagline";
var STR_REMOVE_TAGLINE = "Remove Tagline";
var ID_ACTIVE = '#active_taglines';
function advtag_saveTagline() {
var index = jQuery('#add_index').val();
var textElem = jQuery('#add_text');
var linkElem = jQuery('#add_link');
var targetElem = jQuery('#add_target');
jQuery('#add-tagline img.throbber').show();
var div = null;
if (index != -1) {
div = jQuery(ID_ACTIVE).find('tr.tagline').eq(index);
/* div.find('img').show(); */
}
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: {
action: 'advtag_save',
index: index,
text: textElem.val(),
link: linkElem.val(),
target: targetElem.val()
},
success: function(data){
if (index == -1) {
advtag_newTagline(textElem.val(), linkElem.val(), targetElem.val());
}
else {
var e = advtag_buildTagDiv(textElem.val(), linkElem.val(), targetElem.val());
div.replaceWith(e);
advtag_updateButtons();
}
jQuery('#add_index').val(-1);
textElem.val("");
linkElem.val("");
targetElem.val("");
advtag_tb_remove();
},
complete: function(data) {
jQuery('#add-tagline img').hide();
}
});
}
function advtag_editTag(button)
{
var div = jQuery(button).parent().parent();
var text, link, target;
if (div.find('a').length == 0) {
//text only
text = div.find('p').eq(0).html();
}
else {
var a = div.find('a').eq(0);
text = a.html();
link = a.attr('href');
target = a.attr('target');
}
var index = advtag_getIndex(div);
jQuery('#add_index').val(index);
jQuery('#add_text').val(text);
jQuery('#add_link').val(link);
jQuery('#add_target').val(target);
jQuery('#btn-add-tagline').click();
advtag_switchToEdit();
}
function advtag_getIndex(div) {
var index = -1;
jQuery(ID_ACTIVE).find('tr.tagline').each(function(i, val) {
if (jQuery(val).get(0) == div.get(0)) { index = i; return false; }
});
return index;
}
function advtag_switchToEdit() {
jQuery('#TB_ajaxWindowTitle').html('Edit Tagline');
}
function advtag_newTagline(text, link, target) {
var e = advtag_buildTagDiv(text,link,target);
jQuery(ID_ACTIVE).append(e);
advtag_updateButtons();
}
function advtag_buildTagDiv(text, link, target) {
//TODO: create a class for the tagline elements
var e = jQuery('
'+
' '+
' '+
' '+
''+advtag_buildTagline(text, link, target)+' '+
' '+
' '+
' '+
' ');
//var newElem = jQuery(e);
e.find('input[value=Up]').click(function(event) { advtag_moveUp(this); });
e.find('input[value=Down]').click(function() { advtag_moveDown(this); });
e.find('input[value=Edit]').click(function() { advtag_editTag(this); });
e.find('input[value=Remove]').click(function() { advtag_removeTag(this); });
return e;
}
function advtag_buildTagline(text, link, target) {
var str = '';//";
if (link == "") {
str += '
'+text+'
';
}
else {
str += "
"+text+" ";
}
/* str += "
"; */
return str;
}
function advtag_removeTag(sender) {
if (confirm("Removing a tagline cannot be undone!\n\nAre you sure you want to remove this tagline?") !== true)
{
return;
}
var div = jQuery(sender).parent().parent();
var id = div.find('input[name=id]').val();
div.find('img').show();
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: {
action: 'advtag_remove',
index: id
},
success: function(data){
div.fadeOut(500, function()
{
div.remove();
advtag_updateButtons();
});
},
complete: function() {
div.find('img').hide();
}
});
}
function advtag_updateButtons() {
var e = jQuery(ID_ACTIVE);
e.find('tr.tagline').removeClass('odd').each(advtag_updateRowButtons);
e.find('tr.tagline:odd').addClass('odd');
var count = e.find('tr.tagline').length;
if (count > 0)
{
jQuery('#no-active-taglines').hide();
}
else
{
jQuery('#no-active-taglines').show();
}
}
function advtag_updateRowButtons(index, elem) {
elem = jQuery(elem);
//set sequence
elem.find('input[name=id]').val(index);
//TODO: find a better way to get the buttons
var children = elem.find('input[type=button]');
var moveUpBtn = children.get(0);
var moveDownBtn = children.get(1);
var removeBtn = children.get(3);
if (elem.prev('tr.tagline').length == 0) {
moveUpBtn.disabled = true;
} else {
moveUpBtn.disabled = false;
}
if (elem.next('tr.tagline').length == 0) {
moveDownBtn.disabled = true;
} else {
moveDownBtn.disabled = false;
}
}
function advtag_moveUp(sender) {
var div = jQuery(sender).parent().parent();
var id = div.find('input[name=id]').val();
div.find('img').show();
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: {
action: 'advtag_moveUp',
index: id
},
success: function(data){
var elem = div;
var prev = elem.prev();
elem.after(prev);
advtag_updateButtons();
},
complete: function() {
div.find('img').hide();
}
});
}
function advtag_moveDown(sender) {
var div = jQuery(sender).parent().parent();
var id = div.find('input[name=id]').val();
div.find('img').show();
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: {
action: 'advtag_moveDown',
index: id
},
success: function(data){
var elem = div;
var next = elem.next();
elem.before(next);
advtag_updateButtons();
},
complete: function() {
div.find('img').hide();
}
});
}
jQuery(function() {
jQuery('#form-options').submit(function(){
var form = jQuery(this);
form.find('img').show();
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: form.find(':input').serialize(),
success: function() {
form.find('img').hide();
form.find('span.message').show();
setTimeout('jQuery("#form-options span.message").fadeOut("slow")', 1000);
}
});
return false;
});
// load taglines
jQuery.ajax({
url: advtag_ajaxUrl,
type: 'POST',
dataType: 'json',
data: {action: 'advtag_fetch_taglines'},
success: function(data) {
for(var i = 0; i < data.length; i++)
{
var item = data[i];
advtag_newTagline(item[0], item[1], item[2]);
}
}
});
});
function advtag_focus_form()
{
//need to pause to let the form be "focusable"? weird.
setTimeout("jQuery('#add_text').focus()", 100);
}
var advtag_tb_remove = null; // tb_remove() (thanks scope!)
(function($){
$(function(){
/*
* Thickbox 3 - One Box To Rule Them All.
* By Cody Lindley (http://www.codylindley.com)
* Copyright (c) 2007 cody lindley
* Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
var tb_pathToImage = advtag_pluginDir+"/loadingAnimation.gif";
eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('6 20="2Y/2Z.1I";$(c).2X(9(){1x(\'a.1b, 2W.1b, 2T.1b\');1J=1t 1L();1J.I=20});9 1x(1X){$(1X).l(9(){6 t=W.O||W.1A||J;6 a=W.o||W.2b;6 g=W.2h||P;1g(t,a,g);W.2U();H P})}9 1g(F,d,15){2V{3(2D c.p.C.2C==="2F"){$("p","Z").m({u:"1W%",q:"1W%"});$("Z").m("2q","31");3(c.22("1N")===J){$("p").n(" <4 5=\'s\'>4><4 5=\'8\'>4>");$("#s").l(D)}}b{3(c.22("s")===J){$("p").n("<4 5=\'s\'>4><4 5=\'8\'>4>");$("#s").l(D)}}3(2w()){$("#s").1S("32")}b{$("#s").1S("37")}3(F===J){F=""}$("p").n("<4 5=\'B\'><28 I=\'"+1J.I+"\' />4>");$(\'#B\').38();6 1a;3(d.L("?")!==-1){1a=d.36(0,d.L("?"))}b{1a=d}6 1G=/\\.1T$|\\.1Z$|\\.2j$|\\.1I$|\\.23$/;6 N=1a.1C().2d(1G);3(N==\'.1T\'||N==\'.1Z\'||N==\'.2j\'||N==\'.1I\'||N==\'.23\'){1O="";1M="";12="";1n="";1o="";U="";1P="";1D=P;3(15){A=$("a[@2h="+15+"]").39();2A(v=0;((v &1m;&1m;2R &2Q; 1h>"}b{1O=A[v].O;1M=A[v].o;12="<1h 5=\'2g\'>&1m;&1m;&2P; 2N 1h>"}}b{1D=1k;1P="1L "+(v+1)+" 2O "+(A.1f)}}}M=1t 1L();M.1c=9(){M.1c=J;6 1K=2o();6 x=1K[0]-26;6 y=1K[1]-26;6 j=M.q;6 k=M.u;3(j>x){k=k*(x/j);j=x;3(k>y){j=j*(y/k);k=y}}b 3(k>y){j=j*(y/k);k=y;3(j>x){k=k*(x/j);j=x}}Y=j+30;19=k+3v;$("#8").n("<28 5=\'3a\' I=\'"+d+"\' q=\'"+j+"\' u=\'"+k+"\' 2b=\'"+F+"\'/> "+"<4 5=\'3w\'>"+F+"<4 5=\'3x\'>"+1P+12+U+"4>4><4 5=\'3B\'>1R 1r 1B 1u4>");$("#X").l(D);3(!(12==="")){9 13(){3($(c).K("l",13)){$(c).K("l",13)}$("#8").r();$("p").n("<4 5=\'8\'>4>");1g(1O,1M,15);H P}$("#2g").l(13)}3(!(U==="")){9 1z(){$("#8").r();$("p").n("<4 5=\'8\'>4>");1g(1n,1o,15);H P}$("#2a").l(1z)}c.1l=9(e){3(e==J){G=2t.2E}b{G=e.2l}3(G==27){D()}b 3(G==3e){3(!(U=="")){c.1l="";1z()}}b 3(G==3c){3(!(12=="")){c.1l="";13()}}};16();$("#B").r();$("#24").l(D);$("#8").m({Q:"T"})};M.I=d}b{6 2c=d.2v(/^[^\\?]+\\??/,\'\');6 E=2y(2c);Y=(E[\'q\']*1)+30||3m;19=(E[\'u\']*1)+3l||3j;R=Y-30;S=19-3D;3(d.L(\'2H\')!=-1){1s=d.1Q(\'3n\');$("#18").r();3(E[\'1v\']!="1k"){$("#8").n("<4 5=\'2k\'><4 5=\'1y\'>"+F+"4><4 5=\'1Y\'>1R 1r 1B 1u4>4> ")}b{$("#s").K();$("#8").n(" ")}}b{3($("#8").m("Q")!="T"){3(E[\'1v\']!="1k"){$("#8").n("<4 5=\'2k\'><4 5=\'1y\'>"+F+"4><4 5=\'1Y\'>1R 1r 1B 1u4>4><4 5=\'z\' C=\'q:"+R+"f;u:"+S+"f\'>4>")}b{$("#s").K();$("#8").n("<4 5=\'z\' 3u=\'3q\' C=\'q:"+R+"f;u:"+S+"f;\'>4>")}}b{$("#z")[0].C.q=R+"f";$("#z")[0].C.u=S+"f";$("#z")[0].3k=0;$("#1y").Z(F)}}$("#X").l(D);3(d.L(\'3i\')!=-1){$("#z").n($(\'#\'+E[\'2G\']).2K());$("#8").2z(9(){$(\'#\'+E[\'2G\']).n($("#z").2K())});16();$("#B").r();$("#8").m({Q:"T"})}b 3(d.L(\'2H\')!=-1){16();3($.1H.3g){$("#B").r();$("#8").m({Q:"T"})}}b{$("#z").3r(d+="&1w="+(1t 3o().3d()),9(){16();$("#B").r();1x("#z a.1b");$("#8").m({Q:"T"})})}}3(!E[\'1v\']){c.2s=9(e){3(e==J){G=2t.2E}b{G=e.2l}3(G==27){D()}}}}3f(e){}3p()}9 1q(){$("#B").r();$("#8").m({Q:"T"})}9 D(){$("#3z").K("l");$("#X").K("l");$("#8").3y("3A",9(){$(\'#8,#s,#1N\').3C("2z").K().r()});$("#B").r();3(2D c.p.C.2C=="2F"){$("p","Z").m({u:"2x",q:"2x"});$("Z").m("2q","")}c.1l="";c.2s="";H P}9 16(){$("#8").m({2M:\'-\'+2m((Y/2),10)+\'f\',q:Y+\'f\'});3(!(2r.1H.34&&2r.1H.33<7)){$("#8").m({35:\'-\'+2m((19/2),10)+\'f\'})}}9 2y(1E){6 1e={};3(!1E){H 1e}6 1F=1E.1Q(/[;&]/);2A(6 i=0;i<1F.1f;i++){6 11=1F[i].1Q(\'=\');3(!11||11.1f!=2){3t}6 2B=2I(11[0]);6 1d=2I(11[1]);1d=1d.2v(/\\+/g,\' \');1e[2B]=1d}H 1e}9 2o(){6 14=c.3h;6 w=2J.2u||21.2u||(14&&14.2n)||c.p.2n;6 h=2J.2f||21.2f||(14&&14.25)||c.p.25;2p=[w,h];H 2p}9 2w(){6 1j=2S.1j.1C();3(1j.L(\'3b\')!=-1&&1j.L(\'3s\')!=-1){H 1k}}',62,226,'|||if|div|id|var||TB_window|function||else|document|url||px||||imageWidth|imageHeight|click|css|append|href|body|width|remove|TB_overlay||height|TB_Counter||||TB_ajaxContent|TB_TempArray|TB_load|style|tb_remove|params|caption|keycode|return|src|null|unbind|indexOf|imgPreloader|urlType|title|false|display|ajaxContentW|ajaxContentH|block|TB_NextHTML|iframe|this|TB_closeWindowButton|TB_WIDTH|html||KeyVal|TB_PrevHTML|goPrev|de|imageGroup|tb_position||TB_iframeContent|TB_HEIGHT|baseURL|thickbox|onload|val|Params|length|tb_show|span|Math|userAgent|true|onkeydown|nbsp|TB_NextCaption|TB_NextURL|Close|tb_showIframe|or|urlNoQuery|new|Key|modal|random|tb_init|TB_ajaxWindowTitle|goNext|name|Esc|toLowerCase|TB_FoundURL|query|Pairs|urlString|browser|gif|imgLoader|pagesize|Image|TB_PrevURL|TB_HideSelect|TB_PrevCaption|TB_imageCount|split|close|addClass|jpg|1000|round|100|domChunk|TB_closeAjaxWindow|jpeg|tb_pathToImage|self|getElementById|bmp|TB_ImageOff|clientHeight|150||img||TB_next|alt|queryString|match|hspace|innerHeight|TB_prev|rel|frameborder|png|TB_title|which|parseInt|clientWidth|tb_getPageSize|arrayPageSize|overflow|jQuery|onkeyup|event|innerWidth|replace|tb_detectMacXFF|auto|tb_parseQuery|unload|for|key|maxHeight|typeof|keyCode|undefined|inlineId|TB_iframe|unescape|window|children|urlTypeTemp|marginLeft|Prev|of|lt|gt|Next|navigator|input|blur|try|area|ready|images|loadingAnimation||hidden|TB_overlayMacFFBGHack|version|msie|marginTop|substr|TB_overlayBG|show|get|TB_Image|mac|188|getTime|190|catch|safari|documentElement|TB_inline|440|scrollTop|40|630|TB_|Date|advtag_focus_form|TB_modal|load|firefox|continue|class|60|TB_caption|TB_secondLine|fadeOut|TB_imageOff|fast|TB_closeWindow|trigger|45'.split('|'),0,{}))
advtag_tb_remove = tb_remove;
});
})(jQuery);
jQuery(function() {
//fix throbbers
jQuery('.throbber').attr('src', advtag_pluginDir+'/ajax-loader.gif');
});