');
that.hide().fadeIn();
}
});
jQuery("#admin-ui-tabs").delegate("div.vmicon-16-remove", "click", function () {
jQuery(this).closest(".vm_thumb_image").fadeOut("500", function () {
jQuery(this).remove();
});
});
jQuery("#admin-ui-tabs").delegate("span.vmicon-16-remove", "click", function () {
jQuery(this).closest(".removable").fadeOut("500", function () {
jQuery(this).remove()
});
});
jQuery("#addnewselectimage2").fancybox({
"hideOnContentClick":false,
"autoDimensions":true,
"titlePosition":"inside",
"title":"Media list",
"titleFormat":formatTitle,
"onComplete":function () {
$('.media-pagination').children().eq(page + 3).addClass('media-page-selected');
}
});
container.delegate(".edit-24-grey", "click", function () {
var data = jQuery(this).parent().find("input").val();
jQuery.getJSON("index.php?option=com_virtuemart&view=media&task=viewJson&format=json&virtuemart_media_id=" + data,
function (datas, textStatus) {
if (datas.msg == "OK") {
jQuery("#vm_display_image").attr("src", datas.file_root + datas.file_url);
jQuery("#vm_display_image").attr("alt", datas.file_title);
jQuery("#file_title").html(datas.file_title);
var lang = datas.file_lang.split(',');
jQuery("#vmlangimg").val(lang).trigger("liszt:updated");
if (datas.published == 1) jQuery("#adminForm [name=media_published]").attr('checked', true);
else jQuery("#adminForm [name=media_published]").attr('checked', false);
if (datas.file_is_downloadable == 0) {
jQuery("#media_rolesfile_is_displayable").attr('checked', true);
//jQuery("#adminForm [name=media_roles]").filter("value='file_is_downloadable'").attr('checked', false);
}
else {
//jQuery("#adminForm [name=media_roles]").filter("value='file_is_displayable'").attr('checked', false);
jQuery("#media_rolesfile_is_downloadable").attr('checked', true);
}
jQuery("#adminForm [name=file_title]").val(datas.file_title);
jQuery("#adminForm [name=file_description]").val(datas.file_description);
jQuery("#adminForm [name=file_meta]").val(datas.file_meta);
jQuery("#adminForm [name=file_url]").val(datas.file_url);
jQuery("#adminForm [name=file_url_thumb]").val(datas.file_url_thumb);
jQuery("[name=active_media_id]").val(datas.virtuemart_media_id);
if (datas.file_url_thumb !== "undefined") {
jQuery("#vm_thumb_image").attr("src", datas.file_root + datas.file_url_thumb);
}
else {
jQuery("#vm_thumb_image").attr("src", "");
}
} else jQuery("#file_title").html(datas.msg);
});
});
var display = function (num) {
if (typeof this.page == "undefined") {
this.oldPage = this.page = 0;
}
if (typeof display.cache == "undefined") {
display.cache = new Array();
}
switch (num) {
case '<':
if (this.page > 0) --this.page;
else return;
break;
case '>':
if (this.page < pagetotal - 1) ++this.page;
else return;
break;
case '<<':
this.page = 0;
break;
case '>>':
this.page = pagetotal - 1;
break;
default :
this.page = num - 1;
break;
}
if (this.oldPage != this.page) {
//var cache = this.cache ;
var start = this.page;
if (typeof display.cache[start] == "undefined") {
jQuery.getJSON("index.php?option=com_virtuemart&view=media&task=viewJson&format=json&mediatype=" + mediatype + "&start=" + start,
function (data) {
if (data.imageList != "ERROR") {
display.cache[start] = data.imageList;
jQuery("#media-dialog").html(display.cache[start]);
jQuery(".page").text("Page(s) " + (start + 1));
} else {
jQuery(".page").text("No more results : Page(s) " + (start + 1));
}
}
);
} else jQuery("#media-dialog").html(display.cache[start]);
page = this.oldPage = this.page;
$('.media-pagination').children().removeClass('media-page-selected');
$('.media-pagination').children().eq(start + 3).addClass('media-page-selected');
}
}
},
tips:function (image) {
var xOffset = -20; // x distance from mouse
var yOffset = 10; // y distance from mouse
tip = this;
tip.unbind().hover(
function (e) {
tip.t = this.title;
this.title = '';
tip.top = (e.pageY + yOffset);
tip.left = (e.pageX + xOffset);
$('body').append('
' + $(this).html() + '
' + tip.t + '
');
$('#vtip #vtipArrow').attr("src", image);
$('#vtip').css("top", tip.top + "px").css("left", tip.left + "px").fadeIn("slow");
},
function () {
this.title = tip.t;
$("#vtip").fadeOut("slow").remove();
}
).mousemove(
function (e) {
tip.top = (e.pageY + yOffset);
tip.left = (e.pageX + xOffset);
$("#vtip").css("top", tip.top + "px").css("left", tip.left + "px");
}
).mousedown(
function (e) {
this.title = tip.t;
$("#vtip").fadeOut("slow").remove();
}
).mouseup(
function (e) {
this.title = tip.t;
$("#vtip").fadeOut("slow").remove();
}
);
},
toggle:function () {
var options = { path:'/', expires:2};
if ($.cookie('vmmenu')) {
var status = $.cookie('vmmenu');
if (status == 'hide') {
this.removeClass('vmicon-show').addClass('vmicon-hide');
$('.menu-wrapper').toggle('slide');
}
}
this.click(function () {
$this = $(this);
if ($this.hasClass('vmicon-show')) {
$this.removeClass('vmicon-show').addClass('vmicon-hide');
$('.menu-wrapper').toggle('slide');
$.cookie('vmmenu', 'hide', options);
} else {
$this.removeClass('vmicon-hide').addClass('vmicon-show');
$('.menu-wrapper').toggle('slide');
$.cookie('vmmenu', 'show', options);
}
});
},
yydynoTable:function (options) {
var defaults = {
removeClass:'.row-remover',
cloneClass:'.row-cloner',
addRowTemplateId:'#add-template',
addRowButtonId:'#add-row',
lastRowRemovable:true,
orderable:true,
dragHandleClass:".drag-handle",
insertFadeSpeed:"slow",
removeFadeSpeed:"fast",
hideTableOnEmpty:true,
onRowRemove:function () {
},
onRowClone:function () {
},
onRowAdd:function () {
},
onTableEmpty:function () {
},
onRowReorder:function () {
}
};
options = $.extend(defaults, options);
var cloneRow = function (btn) {
var clonedRow = $(btn).closest('tr').clone();
var tbod = $(btn).closest('tbody');
insertRow(clonedRow, tbod);
options.onRowClone();
}
var insertRow = function (clonedRow, tbod) {
var numRows = $(tbod).children("tr").length;
if (options.hideTableOnEmpty && numRows == 0) {
$(tbod).parents("table").first().show();
}
$(clonedRow).find('*').andSelf().filter('[id]').each(function () {
//change to something else so we don't have ids with the same name
// this.id += "_" + numRows;
});
//finally append new row to end of table
$(tbod).append(clonedRow);
bindActions(clonedRow);
$(tbod).children("tr:last").hide().fadeIn(options.insertFadeSpeed);
}
var removeRow = function (btn) {
var tbod = $(btn).parents("tbody:first");
var numRows = $(tbod).children("tr").length;
if (numRows > 1 || options.lastRowRemovable === true) {
var trToRemove = $(btn).parents("tr:first");
$(trToRemove).fadeOut(options.removeFadeSpeed, function () {
$(trToRemove).remove();
options.onRowRemove();
if (numRows == 1) {
if (options.hideTableOnEmpty) {
$(tbod).parents('table').first().hide();
}
// we want to remove the class remove
$(".price-remove > span").removeClass("vmicon-16-price-remove");
options.onTableEmpty();
}
});
}
}
var bindClick = function (elem, fn) {
$(elem).click(fn);
}
var bindCloneLink = function (lnk) {
bindClick(lnk, function () {
var btn = $(this);
cloneRow(btn);
return false;
});
}
var bindRemoveLink = function (lnk) {
bindClick(lnk, function () {
var btn = $(this);
removeRow(btn);
return false;
});
}
var bindActions = function (obj) {
obj.find(options.removeClass).each(function () {
bindRemoveLink($(this));
});
obj.find(options.cloneClass).each(function () {
bindCloneLink($(this));
});
}
return this.each(function () {
//Sanity check to make sure we are dealing with a single case
if (this.nodeName.toLowerCase() == 'table') {
var table = $(this);
var tbody = $(table).children("tbody").first();
if (options.orderable && jQuery().sortable) {
$(tbody).sortable({
handle:options.dragHandleClass,
helper:function (e, ui) {
ui.children().each(function () {
$(this).width($(this).width());
});
return ui;
},
items:"tr",
update:function (event, ui) {
options.onRowReorder();
}
});
}
$(table).find(options.addRowTemplateId).each(function () {
$(this).removeAttr("id");
var tmpl = $(this);
tmpl.remove();
bindClick($(options.addRowButtonId), function () {
//options.onRowAdd();
var newTr = tmpl.clone();
insertRow(newTr, tbody);
options.onRowAdd();
return false;
});
});
bindActions(table);
var numRows = $(tbody).children("tr").length;
if (options.hideTableOnEmpty && numRows == 0) {
$(table).hide();
}
}
});
}
};
$.fn.vm2admin = function (method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on Vm2 admin jQuery library');
}
};
})(jQuery);
// load defaut scripts
jQuery.noConflict();