Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap

Conflicts:
	admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/modules_positions/form.tpl
	admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/products/input_text_lang.tpl
	admin-dev/themes/default/template/controllers/products/shipping.tpl
	admin-dev/themes/default/template/controllers/shipping/content.tpl
	admin-dev/themes/default/template/helpers/form/form.tpl
	admin-dev/themes/default/template/helpers/list/list_header.tpl
	admin-dev/themes/default/template/toolbar.tpl
	classes/helper/HelperList.php
	controllers/admin/AdminCategoriesController.php
	controllers/admin/AdminManufacturersController.php
	controllers/admin/AdminModulesPositionsController.php
	controllers/admin/AdminPerformanceController.php
	controllers/admin/AdminStockInstantStateController.php
	css/admin.css
	js/admin-products.js
	js/admin.js
This commit is contained in:
Kevin Granger
2013-08-21 09:14:10 +02:00
274 changed files with 9470 additions and 1279 deletions
+1 -1
View File
@@ -1327,7 +1327,7 @@ product_tabs['Suppliers'] = new function(){
collapsible: true,
autoHeight: true,
heightStyle: "content"});
}, 1000);
}, 1000);
// Resize the accordion once the page is visible because of the bug with accordions initialized
// inside a display:none block not having the correct size.
+591
View File
@@ -0,0 +1,591 @@
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
$(document).ready(function() {
validateAndAddRangeButtonDisplay();
bind_inputs();
initCarrierWizard();
if (parseInt($('input[name="is_free"]:checked').val()))
is_freeClick($('input[name="is_free"]:checked'));
displayRangeType();
});
function initCarrierWizard()
{
$("#carrier_wizard").smartWizard({
'labelNext' : labelNext,
'labelPrevious' : labelPrevious,
'labelFinish' : labelFinish,
'fixHeight' : 1,
'onShowStep' : onShowStepCallback,
'onLeaveStep' : onLeaveStepCallback,
'onFinish' : onFinishCallback,
'transitionEffect' : 'slideleft',
'enableAllSteps' : enableAllSteps
});
displayRangeType();
}
function displayRangeType()
{
if ($('input[name="shipping_method"]:checked').val() == 1)
{
string = string_weight;
$('.weight_unit').show();
$('.price_unit').hide();
}
else
{
string = string_price;
$('.price_unit').show();
$('.weight_unit').hide();
}
$('.range_type').html(string);
}
function onShowStepCallback()
{
$('.anchor li a').each( function () {
$(this).parent('li').addClass($(this).attr('class'));
});
$('#carrier_logo_block').prependTo($('div.content').filter(function() { return $(this).css('display') != 'none' }).children('.defaultForm').children('fieldset'));
resizeWizard();
}
function onFinishCallback(obj, context)
{
$('.wizard_error').remove();
$.ajax({
type:"POST",
url : validate_url,
async: false,
dataType: 'json',
data : $('#carrier_wizard .stepContainer .content form').serialize() + '&action=finish_step&ajax=1',
success : function(data) {
if (data.has_error)
{
displayError(data.errors, context.fromStep);
resizeWizard();
}
else
window.location.href = carrierlist_url;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
}
function onLeaveStepCallback(obj, context)
{
if (context.toStep == nbr_steps)
displaySummary();
return validateSteps(context.fromStep); // return false to stay on step and true to continue navigation
}
function displaySummary()
{
// used as buffer - you must not replace directly in the translation vars
var tmp;
// Carrier name
$('#summary_name').html($('#name').val());
// Delay and pricing
tmp = summary_translation_meta_informations.replace('@s2', '<strong>' + $('#delay_1').val() + '</strong>');
if ($('#is_free_on').attr('checked'))
tmp = tmp.replace('@s1', summary_translation_free);
else
tmp = tmp.replace('@s1', summary_translation_paid);
$('#summary_meta_informations').html(tmp);
// Tax and calculation mode for the shipping cost
tmp = summary_translation_shipping_cost.replace('@s2', '<strong>' + $('#id_tax_rules_group option:selected').text() + '</strong>');
if ($('#billing_price').attr('checked'))
tmp = tmp.replace('@s1', summary_translation_price);
else if ($('#billing_weight').attr('checked'))
tmp = tmp.replace('@s1', summary_translation_weight);
else
tmp = tmp.replace('@s1', '<strong>' + summary_translation_undefined + '</strong>');
$('#summary_shipping_cost').html(tmp);
// Weight or price ranges
$('#summary_range').html(summary_translation_range);
var range_inf = summary_translation_undefined;
var range_sup = summary_translation_undefined;
/*
$('input[name$="range_inf[]"]').each(function(){
if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || range_inf < $(this).val()))
range_inf = $(this).val();
});
*/
range_inf = $('tr.range_inf td input:first').val();
range_sup = $('tr.range_sup td input:last').val();
$('input[name$="range_sup[]"]').each(function(){
if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || range_sup > $(this).val()))
range_sup = $(this).val();
});
$('#summary_range').html(
$('#summary_range').html()
.replace('@s1', '<strong>' + range_inf + '</strong>')
.replace('@s2', '<strong>' + range_sup + '</strong>')
.replace('@s3', '<strong>' + $('#range_behavior option:selected').text().toLowerCase() + '</strong>')
);
// Delivery zones
$('#summary_zones').html('');
$('.input_zone').each(function(){
if ($(this).attr('checked'))
$('#summary_zones').html($('#summary_zones').html() + '<li><strong>' + $(this).parent().prev().text() + '</strong></li>');
});
// Group restrictions
$('#summary_groups').html('');
$('input[name$="groupBox[]"]').each(function(){
if ($(this).attr('checked'))
$('#summary_groups').html($('#summary_groups').html() + '<li><strong>' + $(this).parent().next().next().text() + '</strong></li>');
});
// shop restrictions
$('#summary_shops').html('');
$('.input_shop').each(function(){
if ($(this).attr('checked'))
$('#summary_shops').html($('#summary_shops').html() + '<li><strong>' + $(this).parent().text() + '</strong></li>');
});
}
function validateSteps(step_number)
{
$('.wizard_error').remove();
var is_ok = true;
form = $('#carrier_wizard #step-'+step_number+' form');
$.ajax({
type:"POST",
url : validate_url,
async: false,
dataType: 'json',
data : form.serialize()+'&step_number='+step_number+'&action=validate_step&ajax=1',
success : function(datas)
{
if (datas.has_error)
{
is_ok = false;
$('input').focus( function () {
$(this).removeClass('field_error');
});
displayError(datas.errors, step_number);
resizeWizard();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
return is_ok;
}
function displayError(errors, step_number)
{
$('.wizard_error').remove();
str_error = '<div class="error wizard_error" style="display:none"><span style="float:right"><a id="hideError" href="#"><img alt="X" src="../img/admin/close.png" /></a></span><ul>';
for (var error in errors)
{
$('#carrier_wizard').smartWizard('setError',{stepnum:step_number,iserror:true});
$('input[name="'+error+'"]').addClass('field_error');
str_error += '<li>'+errors[error]+'</li>';
}
$('#step-'+step_number).prepend(str_error+'</ul></div>');
$('.wizard_error').fadeIn('fast');
}
function resizeWizard()
{
resizeInterval = setInterval(function (){$("#carrier_wizard").smartWizard('fixHeight'); clearInterval(resizeInterval)}, 100);
}
function bind_inputs()
{
$('input').focus( function () {
$(this).removeClass('field_error');
$('.wizard_error').fadeOut('fast', function () { $(this).remove()});
});
$('tr.delete_range td button').off('click').on('click', function () {
if (confirm(delete_range_confirm))
{
index = $(this).parent('td').index();
$('tr.range_sup td:eq('+index+'), tr.range_inf td:eq('+index+'), tr.fees_all td:eq('+index+'), tr.delete_range td:eq('+index+')').remove();
$('tr.fees').each( function () {
$(this).children('td:eq('+index+')').remove();
});
rebuildTabindex();
}
return false;
});
/*
$('#validate_range_button').off('click').on('click', function () {
index = $('tr.fees_all td:last').index();
if (validateRange(index))
{
enableRange(index);
$('.currency_sign').show();
}
else
disableRange(index);
validateAndAddRangeButtonDisplay();
return false;
});
*/
$('tr.fees td input:checkbox').off('change').on('change', function () {
if($(this).is(':checked'))
{
$(this).closest('tr').children('td').each( function () {
index = $(this).index();
if ($('tr.fees_all td:eq('+index+')').hasClass('validated'))
$(this).children('input:text').removeAttr('disabled');
});
}
else
$(this).closest('tr').children('td').children('input:text').attr('disabled', 'disabled');
return false;
});
$('tr.range_sup td input:text, tr.range_inf td input:text').focus( function () {
$(this).removeClass('field_error');
});
$('tr.range_sup td input:text, tr.range_inf td input:text').keypress( function (evn) {
index = $(this).parent('td').index();
if (evn.keyCode == 13)
{
if (validateRange(index))
enableRange(index);
else
disableRange(index);
validateAndAddRangeButtonDisplay();
return false;
}
});
$('tr.range_sup td input:text, tr.range_inf td input:text').typeWatch({
captureLength: 0,
highlight: false,
wait: 1000,
callback: function() {
index = $(this.el).parent('td').index();
if (validateRange(index))
enableRange(index);
else
disableRange(index);
}
});
$(document.body).off('change', 'tr.fees_all td input').on('change', 'tr.fees_all td input', function() {
   index = $(this).parent('td').index();
val = $(this).val();
$(this).val('');
$('tr.fees').each( function () {
$(this).find('td:eq('+index+') input:text:enabled').val(val);
});
return false;
});
$('input[name="is_free"]').off('click').on('click', function() {
is_freeClick(this);
});
$('input[name="shipping_method"]').off('click').on('click', function() {
$.ajax({
type:"POST",
url : validate_url,
async: false,
dataType: 'html',
data : 'id_carrier='+parseInt($('#id_carrier').val())+'&shipping_method='+parseInt($(this).val())+'&action=changeRanges&ajax=1',
success : function(data) {
$('#zone_ranges').replaceWith(data);
displayRangeType();
bind_inputs();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
});
$('#zones_table td input[type=text]').off('change').on('change', function () {
checkAllFieldIsNumeric();
});
}
function is_freeClick(elt)
{
var is_free = $(elt);
if (parseInt(is_free.val()))
hideFees();
else
showFees();
}
function hideFees()
{
$('tr.range_inf td, tr.range_sup td, tr.fees_all td, tr.fees td').each( function () {
if ($(this).index() >= 2)
{
$(this).find('input:text, button').val('').attr('disabled', 'disabled').css('background-color', '#999999').css('border-color', '#999999');
$(this).css('background-color', '#999999');
}
});
}
function showFees()
{
$('tr.range_inf td, tr.range_sup td, tr.fees_all td, tr.fees td').each( function () {
if ($(this).index() >= 2)
{
//enable only if zone is active
tr = $(this).parent('tr');
if ($(tr).index() > 2 && $(tr).find('td:eq(1) input').attr('checked') && $('tr.fees_all td:eq('+$(this).index()+')').hasClass('validated') || $(tr).hasClass('range_sup') || $(tr).hasClass('range_inf'))
$(this).find('input:text').val('').removeAttr('disabled');
$(this).find('input:text, button').css('background-color', '').css('border-color', '');
$(this).find('button').css('background-color', '').css('border-color', '').removeAttr('disabled');
$(this).css('background-color', '');
}
});
}
function validateRange(index)
{
$('.wizard_error').remove();
//reset error css
$('tr.range_sup td input:text').removeClass('field_error');
$('tr.range_inf td input:text').removeClass('field_error');
is_ok = true;
range_sup = parseFloat($('tr.range_sup td:eq('+index+')').children('input:text').val().trim());
range_inf = parseFloat($('tr.range_inf td:eq('+index+')').children('input:text').val().trim());
if (isNaN(range_sup) || range_sup.length === 0)
{
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
}
else if (is_ok && (isNaN(range_inf) || range_inf.length === 0))
{
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
}
else if (is_ok && range_inf >= range_sup)
{
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
}
else if (is_ok && index > 2) //check range only if it's not the first range
{
$('tr.range_sup td').not('.range_type, .range_sign, tr.range_sup td:last').each( function ()
{
if ($('tr.fees_all td:eq('+index+')').hasClass('validated'))
{
is_ok = false;
curent_index = $(this).index();
current_sup = $(this).find('input').val();
current_inf = $('tr.range_inf td:eq('+curent_index+') input').val();
if ($('tr.range_inf td:eq('+curent_index+1+') input').length)
next_inf = $('tr.range_inf td:eq('+curent_index+1+') input').val();
else
next_inf = false;
//check if range already exist
//check if ranges is overlapping
if ((range_sup != current_sup && range_inf != current_inf) && ((range_sup > current_sup || range_sup <= current_inf) && (range_inf < current_inf || range_inf >= current_sup)))
is_ok = true;
}
});
if (!is_ok)
{
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
displayError([range_is_overlapping], $("#carrier_wizard").smartWizard('currentStep'));
}
else
checkRangeContinuity();
}
return is_ok;
}
function enableRange(index)
{
$('tr.fees').each( function () {
//only enable fees for enabled zones
if ($(this).children('td').children('input:checkbox').attr('checked') == 'checked')
$(this).children('td:eq('+index+')').children('input').removeAttr('disabled');
});
$('span.fees_all').show();
$('tr.fees_all td:eq('+index+')').children('input').show().removeAttr('disabled');
$('tr.fees_all td:eq('+index+')').children('.currency_sign').show();
$('tr.fees_all td:eq('+index+')').addClass('validated').removeClass('not_validated');
$('tr.fees_all td:eq('+index+')').children('button').remove();
bind_inputs();
}
function disableRange(index)
{
$('tr.fees').each( function () {
//only enable fees for enabled zones
if ($(this).children('td').children('input:checkbox').attr('checked') == 'checked')
$(this).children('td:eq('+index+')').children('input').attr('disabled', 'disabled');
});
$('tr.fees_all td:eq('+index+')').children('input').attr('disabled', 'disabled');
$('tr.fees_all td:eq('+index+')').removeClass('validated').addClass('not_validated');
}
function add_new_range()
{
if (!$('tr.fees_all td:last').hasClass('validated'))
{
alert(need_to_validate);
return false;
}
last_sup_val = $('tr.range_sup td:last input').val();
//add new rand sup input
$('tr.range_sup td:last').after('<td class="center"><input name="range_sup[]" type="text" /><sup>*</sup><span class="weight_unit" style="display: none;">&nbsp; '+PS_WEIGHT_UNIT+'</span><span class="price_unit" style="display: none;">&nbsp; '+currency_sign+'</span></td>');
//add new rand inf input
$('tr.range_inf td:last').after('<td class="border_bottom center"><input name="range_inf[]" type="text" value="'+last_sup_val+'" /><sup>*</sup><span class="weight_unit" style="display: none;">&nbsp; '+PS_WEIGHT_UNIT+'</span><span class="price_unit" style="display: none;">&nbsp; '+currency_sign+'</span></td>');
$('tr.fees_all td:last').after('<td class="center border_top border_bottom"><input style="display:none" type="text" /><span class="currency_sign" style="display:none" >&nbsp;'+currency_sign+'</span></td>');
$('tr.fees').each( function () {
$(this).children('td:last').after('<td class="center"><input disabled="disabled" name="fees['+$(this).data('zoneid')+'][]" type="text" /> &nbsp; '+currency_sign+'</td>');
});
$('tr.delete_range td:last').after('<td class="center"><button class="button">'+labelDelete+'</button</td>');
validateAndAddRangeButtonDisplay();
bind_inputs();
rebuildTabindex();
displayRangeType();
resizeWizard();
return false;
}
function delete_new_range()
{
if ($('#new_range_form_placeholder').children('td').length = 1)
return false;
}
function checkAllFieldIsNumeric()
{
$('#zones_table td input[type=text]').each( function () {
if (!$.isNumeric($(this).val()) && $(this).val() != '')
$(this).addClass('field_error');
});
}
function rebuildTabindex()
{
i = 1;
$('#zones_table tr').each( function ()
{
j = i;
$(this).children('td').each( function ()
{
j = zones_nbr + j;
if ($(this).index() >= 2 && $(this).find('input'))
$(this).find('input').attr('tabindex', j);
});
i++;
});
}
function validateAndAddRangeButtonDisplay()
{
return;
if ($('tr.fees_all td:last').hasClass('validated'))
{
$('.validate_range').hide();
$('.new_range').show();
}
else
{
$('.validate_range').show();
$('.new_range').hide();
}
}
function reorderRange(current_index, new_index)
{
$('tr.range_sup, tr.range_inf, tr.fees_all, tr.fees, tr.delete_range ').each(function () {
$(this).find('td:eq('+current_index+')').each( function () {
$(this).parent('tr').find('td:eq('+new_index+')').after(this.outerHTML);
$(this).remove();
});
});
}
function checkRangeContinuity()
{
res = true;
return true;//TODO
$('tr.range_sup td').not('.range_type, .range_sign, tr.range_sup').each( function ()
{
index = $(this).index();
if (index > 2)
{
range_sup = parseFloat($('tr.range_sup td:eq('+index+')').children('input:text').val().trim());
range_inf = parseFloat($('tr.range_inf td:eq('+index+')').children('input:text').val().trim());
prev_index = index-1;
prev_range_sup = parseFloat($('tr.range_sup td:eq('+prev_index+')').children('input:text').val().trim());
prev_range_inf = parseFloat($('tr.range_inf td:eq('+prev_index+')').children('input:text').val().trim());
if (range_inf < prev_range_inf || range_sup < prev_range_sup)
res = false;
}
});
if (res)
$('.ranges_not_follow').fadeOut();
else
$('.ranges_not_follow').fadeIn();
}
+1 -1
View File
@@ -28,7 +28,7 @@ function ajaxStates (id_state_selected)
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+$('#id_country').val() + "&id_state=" + $('#id_state').val(),
data: "ajaxStates=1&no_empty=1&id_country="+$('#id_country').val() + "&id_state=" + $('#id_state').val(),
success: function(html)
{
if (html == 'false')
@@ -0,0 +1,450 @@
/*
* SmartWizard 3.3.1 plugin
* jQuery Wizard control Plugin
* by Dipu
*
* Refactored and extended:
* https://github.com/mstratman/jQuery-Smart-Wizard
*
* Original URLs:
* http://www.techlaboratory.net
* http://tech-laboratory.blogspot.com
*/
function SmartWizard(target, options) {
this.target = target;
this.options = options;
this.curStepIdx = options.selected;
this.steps = $(target).children("ul").children("li").children("a"); // Get all anchors
this.contentWidth = 0;
this.msgBox = $('<div class="msgBox"><div class="content"></div><a href="#" class="close">X</a></div>');
this.elmStepContainer = $('<div></div>').addClass("stepContainer");
this.loader = $('<div>Loading</div>').addClass("loader");
this.buttons = {
next : $('<a>'+options.labelNext+'</a>').attr("href","#").addClass("buttonNext"),
previous : $('<a>'+options.labelPrevious+'</a>').attr("href","#").addClass("buttonPrevious"),
finish : $('<a>'+options.labelFinish+'</a>').attr("href","#").addClass("buttonFinish")
};
/*
* Private functions
*/
var _init = function($this) {
var elmActionBar = $('<div></div>').addClass("actionBar");
elmActionBar.append($this.msgBox);
$('.close',$this.msgBox).click(function() {
$this.msgBox.fadeOut("normal");
return false;
});
var allDivs = $this.target.children('div');
$this.target.children('ul').addClass("anchor");
allDivs.addClass("content");
// highlight steps with errors
if($this.options.errorSteps && $this.options.errorSteps.length>0){
$.each($this.options.errorSteps, function(i, n){
$this.setError({ stepnum: n, iserror:true });
});
}
$this.elmStepContainer.append(allDivs);
elmActionBar.append($this.loader);
$this.target.append($this.elmStepContainer);
elmActionBar.append($this.buttons.finish)
.append($this.buttons.next)
.append($this.buttons.previous);
$this.target.append(elmActionBar);
this.contentWidth = $this.elmStepContainer.width();
$($this.buttons.next).click(function() {
$this.goForward();
return false;
});
$($this.buttons.previous).click(function() {
$this.goBackward();
return false;
});
$($this.buttons.finish).click(function() {
if(!$(this).hasClass('buttonDisabled')){
if($.isFunction($this.options.onFinish)) {
var context = { fromStep: $this.curStepIdx + 1 };
if(!$this.options.onFinish.call(this,$($this.steps), context)){
return false;
}
}else{
var frm = $this.target.parents('form');
if(frm && frm.length){
frm.submit();
}
}
}
return false;
});
$($this.steps).bind("click", function(e){
if($this.steps.index(this) == $this.curStepIdx){
return false;
}
var nextStepIdx = $this.steps.index(this);
var isDone = $this.steps.eq(nextStepIdx).attr("isDone") - 0;
if(isDone == 1){
_loadContent($this, nextStepIdx);
}
return false;
});
// Enable keyboard navigation
if($this.options.keyNavigation){
$(document).keyup(function(e){
if(e.which==39){ // Right Arrow
$this.goForward();
}else if(e.which==37){ // Left Arrow
$this.goBackward();
}
});
}
// Prepare the steps
_prepareSteps($this);
// Show the first slected step
_loadContent($this, $this.curStepIdx);
};
var _prepareSteps = function($this) {
if(! $this.options.enableAllSteps){
$($this.steps, $this.target).removeClass("selected").removeClass("done").addClass("disabled");
$($this.steps, $this.target).attr("isDone",0);
}else{
$($this.steps, $this.target).removeClass("selected").removeClass("disabled").addClass("done");
$($this.steps, $this.target).attr("isDone",1);
}
$($this.steps, $this.target).each(function(i){
$($(this).attr("href").replace(/^.+#/, '#'), $this.target).hide();
$(this).attr("rel",i+1);
});
};
var _step = function ($this, selStep) {
return $(
$(selStep, $this.target).attr("href").replace(/^.+#/, '#'),
$this.target
);
};
var _loadContent = function($this, stepIdx) {
var selStep = $this.steps.eq(stepIdx);
var ajaxurl = $this.options.contentURL;
var ajaxurl_data = $this.options.contentURLData;
var hasContent = selStep.data('hasContent');
var stepNum = stepIdx+1;
if (ajaxurl && ajaxurl.length>0) {
if ($this.options.contentCache && hasContent) {
_showStep($this, stepIdx);
} else {
var ajax_args = {
url: ajaxurl,
type: $this.options.ajaxType,
data: ({step_number : stepNum}),
dataType: "text",
beforeSend: function(){
$this.loader.show();
},
error: function(){
$this.loader.hide();
},
success: function(res){
$this.loader.hide();
if(res && res.length>0){
selStep.data('hasContent',true);
_step($this, selStep).html(res);
_showStep($this, stepIdx);
}
}
};
if (ajaxurl_data) {
ajax_args = $.extend(ajax_args, ajaxurl_data(stepNum));
}
$.ajax(ajax_args);
}
}else{
_showStep($this,stepIdx);
}
};
var _showStep = function($this, stepIdx) {
var selStep = $this.steps.eq(stepIdx);
var curStep = $this.steps.eq($this.curStepIdx);
if(stepIdx != $this.curStepIdx){
if($.isFunction($this.options.onLeaveStep)) {
var context = { fromStep: $this.curStepIdx+1, toStep: stepIdx+1 };
if (! $this.options.onLeaveStep.call($this,$(curStep), context)){
return false;
}
}
}
$this.elmStepContainer.height(_step($this, selStep).outerHeight());
var prevCurStepIdx = $this.curStepIdx;
$this.curStepIdx = stepIdx;
if ($this.options.transitionEffect == 'slide'){
_step($this, curStep).slideUp("fast",function(e){
_step($this, selStep).slideDown("fast");
_setupStep($this,curStep,selStep);
});
} else if ($this.options.transitionEffect == 'fade'){
_step($this, curStep).fadeOut("fast",function(e){
_step($this, selStep).fadeIn("fast");
_setupStep($this,curStep,selStep);
});
} else if ($this.options.transitionEffect == 'slideleft'){
var nextElmLeft = 0;
var nextElmLeft1 = null;
var nextElmLeft = null;
var curElementLeft = 0;
if(stepIdx > prevCurStepIdx){
nextElmLeft1 = $this.elmStepContainer.width() + 10;
nextElmLeft2 = 0;
curElementLeft = 0 - _step($this, curStep).outerWidth();
} else {
nextElmLeft1 = 0 - _step($this, selStep).outerWidth() + 20;
nextElmLeft2 = 0;
curElementLeft = 10 + _step($this, curStep).outerWidth();
}
if (stepIdx == prevCurStepIdx) {
nextElmLeft1 = $($(selStep, $this.target).attr("href"), $this.target).outerWidth() + 20;
nextElmLeft2 = 0;
curElementLeft = 0 - $($(curStep, $this.target).attr("href"), $this.target).outerWidth();
} else {
$($(curStep, $this.target).attr("href"), $this.target).animate({left:curElementLeft},"fast",function(e){
$($(curStep, $this.target).attr("href"), $this.target).hide();
});
}
_step($this, selStep).css("left",nextElmLeft1).show().animate({left:nextElmLeft2},"fast",function(e){
_setupStep($this,curStep,selStep);
});
} else {
_step($this, curStep).hide();
_step($this, selStep).show();
_setupStep($this,curStep,selStep);
}
return true;
};
var _setupStep = function($this, curStep, selStep) {
$(curStep, $this.target).removeClass("selected");
$(curStep, $this.target).addClass("done");
$(selStep, $this.target).removeClass("disabled");
$(selStep, $this.target).removeClass("done");
$(selStep, $this.target).addClass("selected");
$(selStep, $this.target).attr("isDone",1);
_adjustButton($this);
if($.isFunction($this.options.onShowStep)) {
var context = { fromStep: parseInt($(curStep).attr('rel')), toStep: parseInt($(selStep).attr('rel')) };
if(! $this.options.onShowStep.call(this,$(selStep),context)){
return false;
}
}
if ($this.options.noForwardJumping) {
// +2 == +1 (for index to step num) +1 (for next step)
for (var i = $this.curStepIdx + 2; i <= $this.steps.length; i++) {
$this.disableStep(i);
}
}
};
var _adjustButton = function($this) {
if (! $this.options.cycleSteps){
if (0 >= $this.curStepIdx) {
$($this.buttons.previous).addClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.previous).hide();
}
}else{
$($this.buttons.previous).removeClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.previous).show();
}
}
if (($this.steps.length-1) <= $this.curStepIdx){
$($this.buttons.next).addClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.next).hide();
}
}else{
$($this.buttons.next).removeClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.next).show();
}
}
}
// Finish Button
if (! $this.steps.hasClass('disabled') || $this.options.enableFinishButton){
$($this.buttons.finish).removeClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.finish).show();
}
}else{
$($this.buttons.finish).addClass("buttonDisabled");
if ($this.options.hideButtonsOnDisabled) {
$($this.buttons.finish).hide();
}
}
};
/*
* Public methods
*/
SmartWizard.prototype.goForward = function(){
var nextStepIdx = this.curStepIdx + 1;
if (this.steps.length <= nextStepIdx){
if (! this.options.cycleSteps){
return false;
}
nextStepIdx = 0;
}
_loadContent(this, nextStepIdx);
};
SmartWizard.prototype.goBackward = function(){
var nextStepIdx = this.curStepIdx-1;
if (0 > nextStepIdx){
if (! this.options.cycleSteps){
return false;
}
nextStepIdx = this.steps.length - 1;
}
_loadContent(this, nextStepIdx);
};
SmartWizard.prototype.goToStep = function(stepNum){
var stepIdx = stepNum - 1;
if (stepIdx >= 0 && stepIdx < this.steps.length) {
_loadContent(this, stepIdx);
}
};
SmartWizard.prototype.enableStep = function(stepNum) {
var stepIdx = stepNum - 1;
if (stepIdx == this.curStepIdx || stepIdx < 0 || stepIdx >= this.steps.length) {
return false;
}
var step = this.steps.eq(stepIdx);
$(step, this.target).attr("isDone",1);
$(step, this.target).removeClass("disabled").removeClass("selected").addClass("done");
}
SmartWizard.prototype.disableStep = function(stepNum) {
var stepIdx = stepNum - 1;
if (stepIdx == this.curStepIdx || stepIdx < 0 || stepIdx >= this.steps.length) {
return false;
}
var step = this.steps.eq(stepIdx);
$(step, this.target).attr("isDone",0);
$(step, this.target).removeClass("done").removeClass("selected").addClass("disabled");
}
SmartWizard.prototype.currentStep = function() {
return this.curStepIdx + 1;
}
SmartWizard.prototype.showMessage = function (msg) {
$('.content', this.msgBox).html(msg);
this.msgBox.show();
}
SmartWizard.prototype.hideMessage = function () {
this.msgBox.fadeOut("normal");
}
SmartWizard.prototype.showError = function(stepnum) {
this.setError(stepnum, true);
}
SmartWizard.prototype.hideError = function(stepnum) {
this.setError(stepnum, false);
}
SmartWizard.prototype.setError = function(stepnum,iserror) {
if (typeof stepnum == "object") {
iserror = stepnum.iserror;
stepnum = stepnum.stepnum;
}
if (iserror){
$(this.steps.eq(stepnum-1), this.target).addClass('errorStep')
}else{
$(this.steps.eq(stepnum-1), this.target).removeClass("errorStep");
}
}
SmartWizard.prototype.fixHeight = function(){
var height = 0;
var selStep = this.steps.eq(this.curStepIdx);
var stepContainer = _step(this, selStep);
stepContainer.children().each(function() {
height += $(this).outerHeight();
});
// These values (5 and 20) are experimentally chosen.
stepContainer.height(height + 5);
this.elmStepContainer.height(height + 20);
}
_init(this);
};
(function($){
$.fn.smartWizard = function(method) {
var args = arguments;
var rv = undefined;
var allObjs = this.each(function() {
var wiz = $(this).data('smartWizard');
if (typeof method == 'object' || ! method || ! wiz) {
var options = $.extend({}, $.fn.smartWizard.defaults, method || {});
if (! wiz) {
wiz = new SmartWizard($(this), options);
$(this).data('smartWizard', wiz);
}
} else {
if (typeof SmartWizard.prototype[method] == "function") {
rv = SmartWizard.prototype[method].apply(wiz, Array.prototype.slice.call(args, 1));
return rv;
} else {
$.error('Method ' + method + ' does not exist on jQuery.smartWizard');
}
}
});
if (rv === undefined) {
return allObjs;
} else {
return rv;
}
};
// Default Properties and Events
$.fn.smartWizard.defaults = {
selected: 0, // Selected Step, 0 = first step
keyNavigation: true, // Enable/Disable key navigation(left and right keys are used if enabled)
enableAllSteps: false,
transitionEffect: 'fade', // Effect on navigation, none/fade/slide/slideleft
contentURL:null, // content url, Enables Ajax content loading
contentCache:true, // cache step contents, if false content is fetched always from ajax url
cycleSteps: false, // cycle step navigation
enableFinishButton: false, // make finish button enabled always
hideButtonsOnDisabled: false, // when the previous/next/finish buttons are disabled, hide them instead?
errorSteps:[], // Array Steps with errors
labelNext:'Next',
labelPrevious:'Previous',
labelFinish:'Finish',
noForwardJumping: false,
ajaxType: "POST",
onLeaveStep: null, // triggers when leaving a step
onShowStep: null, // triggers when showing a step
onFinish: null // triggers when Finish button is clicked
};
})(jQuery);
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

+13 -3
View File
@@ -186,7 +186,7 @@ function writeBookmarkLink(url, title, text, img)
{
var insert = '';
if (img)
insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + escape(text) + '" />') + '&nbsp';
insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + removeQuotes(text) + '" />') + '&nbsp';
insert += writeBookmarkLinkObject(url, title, text);
if (window.sidebar || window.opera && window.print || (window.external && ('AddFavorite' in window.external)))
document.write(insert);
@@ -195,9 +195,9 @@ function writeBookmarkLink(url, title, text, img)
function writeBookmarkLinkObject(url, title, insert)
{
if (window.sidebar || window.external)
return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + removeQuotes(title) + '\')">' + insert + '</a>');
else if (window.opera && window.print)
return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
return ('<a rel="sidebar" href="' + escape(url) + '" title="' + removeQuotes(title) + '">' + insert + '</a>');
return ('');
}
@@ -284,6 +284,16 @@ function isArrowKey(k_ev)
return false;
}
function removeQuotes(value)
{
value = value.replace(/\\"/g, '');
value = value.replace(/"/g, '');
value = value.replace(/\\'/g, '');
value = value.replace(/'/g, '');
return value;
}
//On dom ready
$().ready(function()
{