Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,436 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
//build confirmation modal
function confirm_modal(heading, question, left_button_txt, right_button_txt, left_button_callback, right_button_callback) {
var confirmModal =
$('<div class="bootstrap modal hide fade">' +
'<div class="modal-dialog">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<a class="close" data-dismiss="modal" >&times;</a>' +
'<h3>' + heading + '</h3>' +
'</div>' +
'<div class="modal-body">' +
'<p>' + question + '</p>' +
'</div>' +
'<div class="modal-footer">' +
'<a href="#" id="confirm_modal_left_button" class="btn btn-primary">' +
left_button_txt +
'</a>' +
'<a href="#" id="confirm_modal_right_button" class="btn btn-primary">' +
right_button_txt +
'</a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>');
confirmModal.find('#confirm_modal_left_button').click(function () {
left_button_callback();
confirmModal.modal('hide');
});
confirmModal.find('#confirm_modal_right_button').click(function () {
right_button_callback();
confirmModal.modal('hide');
});
confirmModal.modal('show');
}
//build error modal
/* global error_continue_msg */
function error_modal(heading, msg) {
var errorModal =
$('<div class="bootstrap modal hide fade">' +
'<div class="modal-dialog">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<a class="close" data-dismiss="modal" >&times;</a>' +
'<h4>' + heading + '</h4>' +
'</div>' +
'<div class="modal-body">' +
'<p>' + msg + '</p>' +
'</div>' +
'<div class="modal-footer">' +
'<a href="#" id="error_modal_right_button" class="btn btn-default">' +
error_continue_msg +
'</a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>');
errorModal.find('#error_modal_right_button').click(function () {
errorModal.modal('hide');
});
errorModal.modal('show');
}
//move to hash after clicking on anchored links
function scroll_if_anchor(href) {
href = typeof(href) === "string" ? href : $(this).attr("href");
var fromTop = 120;
if(href.indexOf("#") === 0) {
var $target = $(href);
if($target.length) {
$('html, body').animate({ scrollTop: $target.offset().top - fromTop });
if(history && "pushState" in history) {
history.pushState({}, document.title, window.location.href + href);
return false;
}
}
}
}
$(document).ready(function() {
$(".nav-bar").find(".link-levelone").hover(function() {
$(this).addClass("-hover");
}, function() {
$(this).removeClass("-hover");
});
$('.nav-bar li.link-levelone.has_submenu > a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
let $submenu = $(this).parent();
$('.nav-bar li.link-levelone.has_submenu a > i.material-icons.sub-tabs-arrow')
.text('keyboard_arrow_down');
let onlyClose = $(e.currentTarget).parent().hasClass('ul-open');
if ($('body').is('.page-sidebar-closed:not(.mobile)')) {
$('.nav-bar li.link-levelone.has_submenu.ul-open').removeClass('ul-open open -hover');
$('.nav-bar li.link-levelone.has_submenu.ul-open ul.submenu').removeAttr('style');
} else {
$('.nav-bar li.link-levelone.has_submenu.ul-open ul.submenu').slideUp({
complete: function() {
$(this).parent().removeClass('ul-open open');
$(this).removeAttr('style');
}
});
}
if (onlyClose) {
return;
}
$submenu.addClass('ul-open');
if ($('body').is('.page-sidebar-closed:not(.mobile)')) {
$submenu.addClass('-hover');
$submenu.find('ul.submenu').removeAttr('style');
} else {
$submenu.find('ul.submenu').slideDown({
complete: function() {
$submenu.addClass('open');
$(this).removeAttr('style');
}
});
}
$submenu.find('i.material-icons.sub-tabs-arrow').text('keyboard_arrow_up');
});
$('.nav-bar').on('click', '.menu-collapse', function() {
$('body').toggleClass('page-sidebar-closed');
if ($('body').hasClass('page-sidebar-closed')) {
$('nav.nav-bar ul.main-menu > li')
.removeClass('ul-open open')
.find('a > i.material-icons.sub-tabs-arrow').text('keyboard_arrow_down');
addMobileBodyClickListener();
} else {
$('nav.nav-bar ul.main-menu > li.-active')
.addClass('ul-open open')
.find('a > i.material-icons.sub-tabs-arrow').text('keyboard_arrow_up');
$('body').off('click.mobile');
}
$.ajax({
url: $(this).data('toggle-url'),
type: 'post',
cache: false,
data: {
shouldCollapse: Number($('body').hasClass('page-sidebar-closed'))
},
});
});
addMobileBodyClickListener();
const MAX_MOBILE_WIDTH = 1023;
if ($(window).width() <= MAX_MOBILE_WIDTH) {
mobileNav(MAX_MOBILE_WIDTH);
}
$(window).on('resize', () => {
if ($('body').hasClass('mobile') && $(window).width() > MAX_MOBILE_WIDTH) {
unbuildMobileMenu();
} else if (!$('body').hasClass('mobile') && $(window).width() <= MAX_MOBILE_WIDTH) {
mobileNav(MAX_MOBILE_WIDTH);
}
});
function addMobileBodyClickListener() {
if (!$('body').is('.page-sidebar-closed:not(.mobile)')) {
return;
}
// To close submenu on mobile devices
$('body').on('click.mobile', function() {
if ($('ul.main-menu li.ul-open').length > 0) {
$('.nav-bar li.link-levelone.has_submenu.ul-open').removeClass('ul-open open -hover');
$('.nav-bar li.link-levelone.has_submenu.ul-open ul.submenu').removeAttr('style');
}
});
}
function mobileNav() {
let $logout = $('#header_logout').addClass('link').removeClass('m-t-1').prop('outerHTML');
var $employee = $('.employee_avatar');
// Legacy
if ($('#employee_links').length > 0) {
$employee = $('<a class="employee_avatar">').attr('href', $('#employee_infos > a.employee_name').attr('href'));
$employee.append($('#employee_links .employee_avatar').clone());
$employee.append($('<span></span>').append($('#employee_links > .username').text()));
}
let profileLink = $('.profile-link').attr('href');
$('.nav-bar li.link-levelone.has_submenu:not(.open) a > i.material-icons.sub-tabs-arrow').text('keyboard_arrow_down');
$('body').addClass('mobile');
$('.nav-bar').addClass('mobile-nav').attr('style', 'margin-left: -100%;');
$('.panel-collapse').addClass('collapse');
$('.link-levelone a').each((index, el)=> {
let id = $(el).parent().find('.collapse').attr('id');
if(id) {
$(el).attr('href', `#${id}`).attr('data-toggle','collapse');
}
});
$('.main-menu').append(`<li class="link-levelone" data-submenu="">${$logout}</li>`);
$('.main-menu').prepend(`<li class="link-levelone">${$employee.prop('outerHTML')}</li>`);
$('.collapse').collapse({
toggle: false
});
if ($('#employee_links').length === 0) {
$('.employee_avatar .material-icons, .employee_avatar span').wrap(`<a href="${profileLink}"></a>`);
}
$('.js-mobile-menu').on('click', expand);
$('.js-notifs_dropdown').css({
'height' : window.innerHeight
});
function expand(e) {
if ($('div.notification-center.dropdown').hasClass('open')) {
return;
}
if ($('.mobile-nav').hasClass('expanded')) {
$('.mobile-nav').animate({'margin-left': '-100%'}, {
complete: function() {
$('.nav-bar, .mobile-layer').removeClass('expanded');
$('.nav-bar, .mobile-layer').addClass('d-none');
}
});
$('.mobile-layer').off();
} else {
$('.nav-bar, .mobile-layer').addClass('expanded');
$('.nav-bar, .mobile-layer').removeClass('d-none');
$('.mobile-layer').on('click', expand);
$('.mobile-nav').animate({'margin-left': 0});
}
}
}
function unbuildMobileMenu() {
$('body').removeClass('mobile');
$('body.page-sidebar-closed .nav-bar .link-levelone.open').removeClass('ul-open open');
$('.main-menu li:first, .main-menu li:last').remove();
$('.js-notifs_dropdown').removeAttr('style');
$('.nav-bar').removeClass('mobile-nav expanded').addClass('d-none').css('margin-left', 0);
$('.js-mobile-menu').off();
$('.panel-collapse').removeClass('collapse').addClass('submenu');
$('.shop-list-title').remove();
$('.js-non-responsive').hide();
$('.mobile-layer').addClass('d-none').removeClass('expanded');
}
//scroll top
function animateGoTop() {
if ($(window).scrollTop()) {
$('#go-top:hidden').stop(true, true).fadeIn();
$('#go-top:hidden').removeClass('hide');
} else {
$('#go-top').stop(true, true).fadeOut();
}
}
//media queries - depends of enquire.js
/*global enquire*/
enquire.register('screen and (max-width: 1200px)', {
match : function() {
if( $('#main').hasClass('helpOpen')) {
$('.toolbarBox a.btn-help').trigger('click');
}
},
unmatch : function() {
}
});
//bootstrap components init
$('.dropdown-toggle').dropdown();
$('.label-tooltip, .help-tooltip').tooltip();
$('#error-modal').modal('show');
// go on top of the page
$('#go-top').on('click',function() {
$('html, body').animate({ scrollTop: 0 }, 'slow');
return false;
});
var timer;
$(window).scroll(function() {
if(timer) {
window.clearTimeout(timer);
}
timer = window.setTimeout(function() {
animateGoTop();
}, 100);
});
// search with nav sidebar closed
$(document).on('click', '.page-sidebar-closed .searchtab' ,function() {
$(this).addClass('search-expanded');
$(this).find('#bo_query').focus();
});
$('.page-sidebar-closed').click(function() {
$('.searchtab').removeClass('search-expanded');
});
$('#header_search button').on('click', function(e){
e.stopPropagation();
});
//erase button search input
if ($('#bo_query').val() !== '') {
$('.clear_search').removeClass('hide');
}
$('.clear_search').on('click', function(e){
e.stopPropagation();
e.preventDefault();
var id = $(this).closest('form').attr('id');
$('#'+id+' #bo_query').val('').focus();
$('#'+id+' .clear_search').addClass('hide');
});
$('#bo_query').on('keydown', function(){
if ($('#bo_query').val() !== ''){
$('.clear_search').removeClass('hide');
}
});
//search with nav sidebar opened
$('.page-sidebar').click(function() {
$('#header_search .form-group').removeClass('focus-search');
});
$('#header_search #bo_query').on('click', function(e){
e.stopPropagation();
e.preventDefault();
if($('body').hasClass('mobile-nav')){
return false;
}
$('#header_search .form-group').addClass('focus-search');
});
//select list for search type
$('#header_search_options').on('click','li a', function(e){
e.preventDefault();
$('#header_search_options .search-option').removeClass('active');
$(this).closest('li').addClass('active');
$('#bo_search_type').val($(this).data('value'));
$('#search_type_icon').removeAttr("class").addClass($(this).data('icon'));
$('#bo_query').attr("placeholder",$(this).data('placeholder'));
$('#bo_query').focus();
});
// reset form
/* global header_confirm_reset, body_confirm_reset, left_button_confirm_reset, right_button_confirm_reset */
$(".reset_ready").click(function () {
var href = $(this).attr('href');
confirm_modal( header_confirm_reset, body_confirm_reset, left_button_confirm_reset, right_button_confirm_reset,
function () {
window.location.href = href + '&keep_data=1';
},
function () {
window.location.href = href + '&keep_data=0';
});
return false;
});
//scroll_if_anchor(window.location.hash);
$("body").on("click", "a.anchor", scroll_if_anchor);
//manage curency status switcher
$('#currencyStatus input').change(function(){
var parentZone = $(this).parent().parent().parent().parent();
parentZone.find('.status').addClass('hide');
if($(this).attr('checked') == 'checked'){
parentZone.find('.enabled').removeClass('hide');
$('#currency_form #active').val(1);
}else{
parentZone.find('.disabled').removeClass('hide');
$('#currency_form #active').val(0);
}
});
$('#currencyCronjobLiveExchangeRate input').change(function(){
var enable = 0;
var parentZone = $(this).parent().parent().parent().parent();
parentZone.find('.status').addClass('hide');
if($(this).attr('checked') == 'checked'){
enable = 1;
parentZone.find('.enabled').removeClass('hide');
}else{
enable = 0;
parentZone.find('.disabled').removeClass('hide');
}
$.ajax({
url: "index.php?controller=AdminCurrencies&token="+token,
cache: false,
data: "ajax=1&action=cronjobLiveExchangeRate&tab=AdminCurrencies&enable="+enable
});
});
// Order details: show modal to update shipping details
$(document).on('click', '.edit_shipping_link', function(e) {
e.preventDefault();
$('#id_order_carrier').val($(this).data('id-order-carrier'));
$('#shipping_tracking_number').val($(this).data('tracking-number'));
$('#shipping_carrier option[value='+$(this).data('id-carrier')+']').prop('selected', true);
$('#modal-shipping').modal();
});
});

View File

@@ -0,0 +1,119 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
function PerformancePage(addServerUrl, removeServerUrl, testServerUrl) {
this.addServerUrl = addServerUrl;
this.removeServerUrl = removeServerUrl;
this.testServerUrl = testServerUrl;
this.getAddServerUrl = function() {
return this.addServerUrl;
};
this.getRemoveServerlUrl = function() {
return this.removeServerUrl;
};
this.getTestServerUrl = function() {
return this.testServerUrl;
};
this.getFormValues = function() {
var serverIpInput = document.getElementById('form_add_memcache_server_memcache_ip');
var serverPortInput = document.getElementById('form_add_memcache_server_memcache_port');
var serverWeightInput = document.getElementById('form_add_memcache_server_memcache_weight');
return {
'server_ip': serverIpInput.value,
'server_port': serverPortInput.value,
'server_weight': serverWeightInput.value,
};
};
this.createRow = function(params) {
var serversTable = document.getElementById('servers-table');
var newRow = document.createElement('tr');
newRow.setAttribute('id', 'row_'+ params.id);
newRow.innerHTML =
'<td>'+ params.id +'</td>\n' +
'<td>'+ params.server_ip +'</td>\n' +
'<td>'+ params.server_port +'</td>\n' +
'<td>'+ params.server_weight +'</td>\n' +
'<td>\n' +
' <a class="btn btn-default" href="#" onclick="app.removeServer('+ params.id +');"><i class="material-icons">remove_circle</i> Remove</a>\n' +
'</td>\n';
serversTable.appendChild(newRow);
};
this.addServer = function() {
var app = this;
this.send(this.getAddServerUrl(), 'POST', this.getFormValues(), function(results) {
if (!results.hasOwnProperty('error')) {
app.createRow(results);
}
});
};
this.removeServer = function(serverId, removeMsg) {
var removeOk = confirm(removeMsg);
if (removeOk) {
this.send(this.getRemoveServerlUrl(), 'DELETE', {'server_id': serverId}, function(results) {
if (results === undefined) {
var row = document.getElementById('row_'+serverId);
row.parentNode.removeChild(row);
}
});
}
};
this.testServer = function() {
var app = this;
this.send(this.getTestServerUrl(), 'GET', this.getFormValues(), function(results) {
if (results.hasOwnProperty('error') || results.test === false) {
app.addClass('is-invalid');
return;
}
app.addClass('is-valid');
});
};
this.addClass = function(className) {
var serverFormInputs = document.querySelectorAll('#server-form input[type=text]');
for (var i = 0; i < serverFormInputs.length; i++) {
serverFormInputs[i].className = 'form-control '+ className;
}
}
/* global $ */
this.send = function(url, method, params, callback) {
return $.ajax({
url: url,
method: method,
data: params
}).done(callback);
};
}

View File

@@ -0,0 +1,104 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
var PerformancePageUI = {
displaySmartyCache: function() {
var CACHE_ENABLED = '1';
var smartyCacheSelected = document.querySelector('input[name="form[smarty][cache]"]:checked');
var smartyCacheOptions = document.querySelectorAll('.smarty-cache-option');
if (smartyCacheSelected && smartyCacheSelected.value === CACHE_ENABLED) {
for(var i = 0; i < smartyCacheOptions.length; i++) {
smartyCacheOptions[i].classList.remove('d-none');
}
return;
}
for(var i = 0; i < smartyCacheOptions.length; i++) {
smartyCacheOptions[i].classList.add('d-none');
}
},
displayCacheSystems: function() {
var CACHE_ENABLED = '1';
var cacheEnabledInput = document.querySelector('input[name="form[caching][use_cache]"]:checked');
var cachingElements = document.getElementsByClassName('memcache');
if(cacheEnabledInput.value === CACHE_ENABLED) {
for (var i = 0; i < cachingElements.length; i++) {
cachingElements[i].style.display = "block";
}
return;
}
for (var i = 0; i < cachingElements.length; i++) {
cachingElements[i].style.display = "none";
}
},
displayMemcacheServers: function() {
var CACHE_ENABLED = '1';
var cacheEnabledInput = document.querySelector('input[name="form[caching][use_cache]"]:checked');
var cacheSelected = document.querySelector('input[name="form[caching][caching_system]"]:checked');
var memcacheServersListBlock = document.getElementById('servers-list');
var newServerBtn = document.getElementById('new-server-btn');
var isMemcache = cacheSelected && (cacheSelected.value === "CacheMemcache" || cacheSelected.value === "CacheMemcached");
if (isMemcache && cacheEnabledInput.value === CACHE_ENABLED) {
memcacheServersListBlock.style.display = "block";
newServerBtn.style.display = "block";
return;
}
memcacheServersListBlock.style.display = "none";
newServerBtn.style.display = "none";
}
};
/**
* Animations on form values.
*/
window.addEventListener('load', function() {
PerformancePageUI.displaySmartyCache();
PerformancePageUI.displayCacheSystems();
PerformancePageUI.displayMemcacheServers();
});
var cacheSystemInputs = document.querySelectorAll('input[type=radio]');
var length = cacheSystemInputs.length;
while(length--) {
cacheSystemInputs[length].addEventListener('change', function(e) {
var name = e.target.getAttribute('name');
if ('form[caching][use_cache]' === name) {
return PerformancePageUI.displayCacheSystems();
}
if ('form[smarty][cache]' === name) {
return PerformancePageUI.displaySmartyCache();
}
if ('form[caching][caching_system]' === name) {
return PerformancePageUI.displayMemcacheServers();
}
});
}

View File

@@ -0,0 +1,89 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
(function ($) {
$.fn.categorytree = function (settings) {
var isMethodCall = (typeof settings === 'string'), // is this a method call like $().categorytree("unselect")
returnValue = this;
// if a method call execute the method on all selected instances
if (isMethodCall) {
switch (settings) {
case 'unselect':
this.find('.radio > label > input:radio').prop('checked', false);
// TODO: add a callback method feature?
break;
case 'unfold':
this.find('ul').show();
this.find('li').has('ul').removeClass('more').addClass('less');
break;
case 'fold':
this.find('ul ul').hide();
this.find('li').has('ul').removeClass('less').addClass('more');
break;
default:
throw 'Unknown method';
}
}
// initialize tree
else {
var clickHandler = function (event) {
var $ui = $(event.target);
if ($ui.attr('type') === 'radio' || $ui.attr('type') === 'checkbox') {
return;
} else {
event.stopPropagation();
}
if ($ui.next('ul').length === 0) {
$ui = $ui.parent();
}
$ui.next('ul').toggle();
if ($ui.next('ul').is(':visible')) {
$ui.parent('li').removeClass('more').addClass('less');
} else {
$ui.parent('li').removeClass('less').addClass('more');
}
return false;
};
this.find('li > ul').each(function (i, item) {
var $inputWrapper = $(item).prev('div');
$inputWrapper.on('click', clickHandler);
$inputWrapper.find('label').on('click', clickHandler);
if ($(item).is(':visible')) {
$(item).parent('li').removeClass('more').addClass('less');
} else {
$(item).parent('li').removeClass('less').addClass('more');
}
});
}
// return the jquery selection (or if it was a method call that returned a value - the returned value)
return returnValue;
};
})(jQuery);

View File

@@ -0,0 +1,86 @@
/**
* Default layout instanciation
*/
$(document).ready(function() {
var $this = $(this);
var $ajaxSpinner = $('.ajax-spinner');
$('[data-toggle="tooltip"]').tooltip();
rightSidebar.init();
/** spinner loading */
$this.ajaxStart(function () {
$ajaxSpinner.show();
});
$this.ajaxStop(function () {
$ajaxSpinner.hide();
});
$this.ajaxError(function () {
$ajaxSpinner.hide();
});
});
var rightSidebar = (function() {
return {
'init': function() {
$('.btn-sidebar').on('click', function initLoadQuickNav() {
$('div.right-sidebar-flex').removeClass('col-lg-12').addClass('col-lg-9');
/** Lazy load of sidebar */
var url = $(this).data('url');
var target = $(this).data('target');
if (url) {
rightSidebar.loadQuickNav(url,target);
}
});
$(document).on('hide.bs.sidebar', function(e) {
$('div.right-sidebar-flex').removeClass('col-lg-9').addClass('col-lg-12');
});
},
'loadQuickNav': function(url, target) {
/** Loads inner HTML in the sidebar container */
$(target).load(url, function() {
$(this).removeAttr('data-url');
$('ul.pagination > li > a[href]', this).on('click', function(e) {
e.preventDefault();
rightSidebar.navigationChange($(e.target).attr('href'), $(target));
});
$('ul.pagination > li > input[name="paginator_jump_page"]', this).on('keyup', function(e) {
if (e.which === 13) { // ENTER
e.preventDefault();
var val = parseInt($(e.target).val());
var limit = $(e.target).attr('pslimit');
var url = $(this).attr('psurl').replace(/999999/, (val-1)*limit);
rightSidebar.navigationChange(url, $(target));
}
});
});
},
'navigationChange': function(url, sidebar) {
rightSidebar.loadQuickNav(url, sidebar);
}
};
})();
/**
* BO Events Handler
*/
var BOEvent = {
on: function(eventName, callback, context) {
document.addEventListener(eventName, function(event) {
if (typeof context !== 'undefined') {
callback.call(context, event);
} else {
callback(event);
}
});
},
emitEvent: function(eventName, eventType) {
var _event = document.createEvent(eventType);
// true values stand for: can bubble, and is cancellable
_event.initEvent(eventName, true, true);
document.dispatchEvent(_event);
}
};

View File

@@ -0,0 +1,59 @@
/**
* modal confirmation management
*/
var modalConfirmation = (function() {
var modal = $('#confirmation_modal');
if(!modal) {
throw new Error('Modal confirmation is not available');
}
var actionsCallbacks = {
onCancel: function() {
console.log('modal canceled');
return;
},
onContinue: function() {
console.log('modal continued');
return;
}
};
modal.find('button.cancel').click(function() {
if (typeof actionsCallbacks.onCancel === 'function') {
actionsCallbacks.onCancel();
}
modalConfirmation.hide();
});
modal.find('button.continue').click(function() {
if (typeof actionsCallbacks.onContinue === 'function') {
actionsCallbacks.onContinue();
}
modalConfirmation.hide();
});
return {
'init': function init() {},
'create': function create(content, title, callbacks) {
if(title != null){
modal.find('.modal-title').html(title);
}
if(content != null){
modal.find('.modal-body').html(content);
}
actionsCallbacks = callbacks;
return this;
},
'show': function show() {
modal.modal('show');
},
'hide': function hide() {
modal.modal('hide');
}
};
})();
BOEvent.on("Modal confirmation started", function initModalConfirmationSystem() {
modalConfirmation.init();
}, "Back office");

View File

@@ -0,0 +1,53 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
$(function() {
var moduleImport = $("#module-import");
moduleImport.click(function() {
moduleImport.addClass("onclick", 250, validate);
});
function validate() {
setTimeout(function() {
moduleImport.removeClass("onclick");
moduleImport.addClass("validate", 450, callback);
}, 2250 );
}
function callback() {
setTimeout(function() {
moduleImport.removeClass("validate");
}, 1250 );
}
$('body').on('click', 'a.module-read-more-grid-btn, a.module-read-more-list-btn', function (event) {
event.preventDefault();
var urlCallModule = event.target.href;
var modulePoppin = $(event.target).data('target');
$.get(urlCallModule, function (data) {
$(modulePoppin).html(data);
$(modulePoppin).modal();
});
});
});

View File

@@ -0,0 +1,943 @@
$(document).ready(function() {
var controller = new AdminModuleController();
controller.init();
});
/**
* Module Admin Page Controller.
* @constructor
*/
var AdminModuleController = function() {
this.currentDisplay = '';
this.isCategoryGridDisplayed = false;
this.currentTagsList = [];
this.currentRefCategory = null;
this.currentRefStatus = null;
this.currentSorting = null;
this.baseAddonsUrl = 'https://addons.prestashop.com/';
this.pstaggerInput = null;
this.lastBulkAction = null;
this.isUploadStarted = false;
/**
* Loaded modules list.
* Containing the card and list display.
* @type {Array}
*/
this.modulesList = [];
this.addonsCardGrid = null;
this.addonsCardList = null;
// Selectors into vars to make it easier to change them while keeping same code logic
this.moduleItemGridSelector = '.module-item-grid';
this.moduleItemListSelector = '.module-item-list';
this.categorySelectorLabelSelector = '.module-category-selector-label';
this.categorySelector = '.module-category-selector';
this.categoryItemSelector = '.module-category-menu';
this.addonsLoginButtonSelector = '#addons_login_btn';
this.categoryResetBtnSelector = '.module-category-reset';
this.moduleInstallBtnSelector = 'input.module-install-btn';
this.moduleSortingDropdownSelector = '.module-sorting-author select';
this.categoryGridSelector = '#modules-categories-grid';
this.categoryGridItemSelector = '.module-category-item';
this.addonItemGridSelector = '.module-addons-item-grid';
this.addonItemListSelector = '.module-addons-item-list';
// Upgrade All selectors
this.upgradeAllSource = '.module_action_menu_upgrade_all';
this.upgradeAllTargets = '#modules-list-container-update .module_action_menu_upgrade:visible';
// Bulk action selectors
this.bulkActionDropDownSelector = '.module-bulk-actions select';
this.checkedBulkActionListSelector = '.module-checkbox-bulk-list input:checked';
this.checkedBulkActionGridSelector = '.module-checkbox-bulk-grid input:checked';
this.bulkActionCheckboxGridSelector = '.module-checkbox-bulk-grid';
this.bulkActionCheckboxListSelector = '.module-checkbox-bulk-list';
this.bulkActionCheckboxSelector = '#module-modal-bulk-checkbox';
this.bulkConfirmModalSelector = '#module-modal-bulk-confirm';
this.bulkConfirmModalActionNameSelector = '#module-modal-bulk-confirm-action-name';
this.bulkConfirmModalListSelector = '#module-modal-bulk-confirm-list';
this.bulkConfirmModalAckBtnSelector = '#module-modal-confirm-bulk-ack';
// Placeholders
this.placeholderGlobalSelector = '.module-placeholders-wrapper';
this.placeholderFailureGlobalSelector = '.module-placeholders-failure';
this.placeholderFailureMsgSelector = '.module-placeholders-failure-msg';
this.placeholderFailureRetryBtnSelector = '#module-placeholders-failure-retry';
// Module's statuses selectors
this.statusSelectorLabelSelector = '.module-status-selector-label';
this.statusItemSelector = '.module-status-menu';
this.statusResetBtnSelector = '.module-status-reset';
// Selectors for Module Import and Addons connect
this.addonsConnectModalBtnSelector = '#page-header-desc-configuration-addons_connect';
this.addonsLogoutModalBtnSelector = '#page-header-desc-configuration-addons_logout';
this.addonsImportModalBtnSelector = '#page-header-desc-configuration-add_module';
this.dropZoneModalSelector = '#module-modal-import';
this.dropZoneModalFooterSelector = '#module-modal-import .modal-footer';
this.dropZoneImportZoneSelector = '#importDropzone';
this.addonsConnectModalSelector = '#module-modal-addons-connect';
this.addonsLogoutModalSelector = '#module-modal-addons-logout';
this.addonsConnectForm = '#addons-connect-form';
this.moduleImportModalCloseBtn = '#module-modal-import-closing-cross';
this.moduleImportStartSelector = '.module-import-start';
this.moduleImportProcessingSelector = '.module-import-processing';
this.moduleImportSuccessSelector = '.module-import-success';
this.moduleImportSuccessConfigureBtnSelector = '.module-import-success-configure';
this.moduleImportFailureSelector = '.module-import-failure';
this.moduleImportFailureRetrySelector = '.module-import-failure-retry';
this.moduleImportFailureDetailsBtnSelector = '.module-import-failure-details-action';
this.moduleImportSelectFileManualSelector = '.module-import-start-select-manual';
this.moduleImportFailureMsgDetailsSelector = '.module-import-failure-details';
this.moduleImportConfirmSelector = '.module-import-confirm';
/**
* Initialize all listners and bind everything
* @method init
* @memberof AdminModule
*/
this.init = function () {
this.initBOEventRegistering();
this.loadVariables();
this.initSortingDisplaySwitch();
this.initSortingDropdown();
this.initSearchBlock();
this.initCategorySelect();
this.initCategoriesGrid();
this.initActionButtons();
this.initAddonsSearch();
this.initAddonsConnect();
this.initAddModuleAction();
this.initDropzone();
this.initPageChangeProtection();
this.initBulkActions();
this.initPlaceholderMechanism();
this.initFilterStatusDropdown();
this.fetchModulesList();
this.getNotificationsCount();
};
this.initFilterStatusDropdown = function() {
var self = this;
var body = $('body');
body.on('click', this.statusItemSelector, function () {
// Get data from li DOM input
self.currentRefStatus = parseInt($(this).attr('data-status-ref'));
var statusSelectedDisplayName = $(this).find('a:first').text();
// Change dropdown label to set it to the current status' displayname
$(self.statusSelectorLabelSelector).text(statusSelectedDisplayName);
$(self.statusResetBtnSelector).show();
// Do Search on categoryRef
self.updateModuleVisibility();
});
body.on('click', this.statusResetBtnSelector, function () {
var text = $(this).find('a').text();
$(self.statusSelectorLabelSelector).text(text);
$(this).hide();
self.currentRefStatus = null;
self.updateModuleVisibility();
});
};
this.initBOEventRegistering = function() {
BOEvent.on('Module Disabled', this.onModuleDisabled, this);
BOEvent.on('Module Uninstalled', this.updateTotalResults, this);
};
this.onModuleDisabled = function() {
var moduleItemSelector = this.getModuleItemSelector();
var self = this;
$('.modules-list').each(function() {
var totalForCurrentSelector = $(this).find(moduleItemSelector+':visible').length;
self.updateTotalResults(totalForCurrentSelector, $(this));
});
};
this.initPlaceholderMechanism = function() {
var self = this;
if ($(this.placeholderGlobalSelector).length) {
this.ajaxLoadPage();
}
// Retry loading mechanism
$('body').on('click', this.placeholderFailureRetryBtnSelector, function() {
$(self.placeholderFailureGlobalSelector).fadeOut();
$(self.placeholderGlobalSelector).fadeIn();
self.ajaxLoadPage();
});
};
this.ajaxLoadPage = function() {
var self = this;
$.ajax({
method: 'GET',
url: moduleURLs.catalogRefresh
}).done(function (response) {
if (response.status === true) {
if (typeof response.domElements === 'undefined') response.domElements = null;
if (typeof response.msg === 'undefined') response.msg = null;
var stylesheet = document.styleSheets[0];
var stylesheetRule = '{display: none}';
var moduleGlobalSelector = '.modules-list';
var moduleSortingSelector = '.module-sorting-menu';
var requiredSelectorCombination = moduleGlobalSelector + ', ' + moduleSortingSelector;
if (stylesheet.insertRule) {
stylesheet.insertRule(
requiredSelectorCombination +
stylesheetRule, stylesheet.cssRules.length
);
} else if (stylesheet.addRule) {
stylesheet.addRule(
requiredSelectorCombination,
stylesheetRule,
-1
);
}
$(self.placeholderGlobalSelector).fadeOut(800, function() {
$.each(response.domElements, function(index, element){
$(element.selector).append(element.content);
});
$(moduleGlobalSelector).fadeIn(800).css('display','flex');
$(moduleSortingSelector).fadeIn(800);
$('[data-toggle="popover"]').popover();
self.initCurrentDisplay();
self.fetchModulesList();
});
} else {
$(self.placeholderGlobalSelector).fadeOut(800, function() {
$(self.placeholderFailureMsgSelector).text(response.msg);
$(self.placeholderFailureGlobalSelector).fadeIn(800);
});
}
}).fail(function(response) {
$(self.placeholderGlobalSelector).fadeOut(800, function() {
$(self.placeholderFailureMsgSelector).text(response.statusText);
$(self.placeholderFailureGlobalSelector).fadeIn(800);
});
});
};
this.fetchModulesList = function() {
var self = this;
self.modulesList = [];
$(".modules-list").each(function() {
var container = $(this);
container.find(".module-item").each(function() {
var $this = $(this);
self.modulesList.push({
domObject: $this,
id: $this.attr('data-id'),
name: $this.attr('data-name').toLowerCase(),
scoring: parseFloat($this.attr('data-scoring')),
logo: $this.attr('data-logo'),
author: $this.attr('data-author').toLowerCase(),
version: $this.attr('data-version'),
description: $this.attr('data-description').toLowerCase(),
techName: $this.attr('data-tech-name').toLowerCase(),
childCategories: $this.attr('data-child-categories'),
categories: $this.attr('data-categories').toLowerCase(),
type: $this.attr('data-type'),
price: parseFloat($this.attr('data-price')),
active: parseInt($this.attr('data-active')),
access: $this.attr('data-last-access'),
display: $this.hasClass('module-item-list') ? 'list' : 'grid',
container: container
});
$this.remove();
});
});
self.addonsCardGrid = $(this.addonItemGridSelector);
self.addonsCardList = $(this.addonItemListSelector);
this.updateModuleVisibility();
$('body').trigger('moduleCatalogLoaded');
};
this.updateModuleVisibility = function() {
var self = this;
if (self.currentSorting) {
// Modules sorting
var order = 'asc';
var key = self.currentSorting;
if (key.split('-').length > 1) {
key = key.split('-')[0];
}
if (self.currentSorting.indexOf('-desc') != -1) {
order = 'desc';
}
function currentCompare(a, b) {
if (a[key] < b[key]) return -1;
if (a[key] > b[key]) return 1;
return 0;
}
self.modulesList.sort(currentCompare);
if (order == 'desc') {
self.modulesList.reverse();
}
}
$('.modules-list').html('');
// Modules visibility management
for (var i = 0; i < this.modulesList.length; i++) {
var currentModule = this.modulesList[i];
if (currentModule.display == this.currentDisplay) {
var isVisible = true;
if (this.currentRefCategory !== null) {
isVisible &= currentModule.categories === this.currentRefCategory;
}
if (self.currentRefStatus !== null) {
isVisible &= currentModule.active === this.currentRefStatus;
}
if (self.currentTagsList.length) {
var tagExists = false;
$.each(self.currentTagsList, function(index, value) {
value = value.toLowerCase();
tagExists |= (
currentModule.name.indexOf(value) != -1
|| currentModule.description.indexOf(value) != -1
|| currentModule.author.indexOf(value) != -1
|| currentModule.techName.indexOf(value) != -1
);
});
isVisible &= tagExists;
}
if (isVisible) {
currentModule.container.append(currentModule.domObject);
}
}
}
if (this.currentTagsList.length) {
if ('grid' === this.currentDisplay) {
$(".modules-list").append(this.addonsCardGrid);
} else {
$(".modules-list").append(this.addonsCardList);
}
}
this.updateTotalResults();
};
this.initPageChangeProtection = function() {
var self = this;
$(window).on('beforeunload', function() {
if (self.isUploadStarted === true) {
return "It seems some critical operation are running, are you sure you want to change page ? It might cause some unexepcted behaviors.";
}
});
};
this.initBulkActions = function() {
var self = this;
var body = $('body');
body.on('change', this.bulkActionDropDownSelector, function() {
if (0 === $(self.getBulkCheckboxesCheckedSelector()).length) {
$.growl.warning({message: translate_javascripts['Bulk Action - One module minimum']});
return;
}
self.lastBulkAction = $(this).find(':checked').attr('value');
var modulesListString = self.buildBulkActionModuleList();
var actionString = $(this).find(':checked').text().toLowerCase();
$(self.bulkConfirmModalListSelector).html(modulesListString);
$(self.bulkConfirmModalActionNameSelector).text(actionString);
if (self.lastBulkAction !== 'bulk-uninstall') {
$(self.bulkActionCheckboxSelector).hide();
}
$(self.bulkConfirmModalSelector).modal('show');
});
body.on('click', this.bulkConfirmModalAckBtnSelector, function(event) {
event.preventDefault();
event.stopPropagation();
$(self.bulkConfirmModalSelector).modal('hide');
self.doBulkAction(self.lastBulkAction);
});
};
this.buildBulkActionModuleList = function() {
var checkBoxesSelector = this.getBulkCheckboxesCheckedSelector();
var moduleItemSelector = this.getModuleItemSelector();
var alreadyDoneFlag = 0;
var htmlGenerated = '';
$(checkBoxesSelector).each(function() {
if (alreadyDoneFlag != 10) {
var currentElement = $(this).parents(moduleItemSelector);
htmlGenerated += '- ' + currentElement.attr('data-name') + '<br/>';
alreadyDoneFlag += 1;
} else {
// Break each
htmlGenerated += '- ...';
return false;
}
});
return htmlGenerated;
};
this.initAddonsConnect = function () {
var self = this;
// Make addons connect modal ready to be clicked
if ($(this.addonsConnectModalBtnSelector).attr('href') == '#') {
$(this.addonsConnectModalBtnSelector).attr('data-toggle', 'modal');
$(this.addonsConnectModalBtnSelector).attr('data-target', this.addonsConnectModalSelector);
}
if ($(this.addonsLogoutModalBtnSelector).attr('href') == '#') {
$(this.addonsLogoutModalBtnSelector).attr('data-toggle', 'modal');
$(this.addonsLogoutModalBtnSelector).attr('data-target', this.addonsLogoutModalSelector);
}
$('body').on('submit', this.addonsConnectForm, function (event) {
event.preventDefault();
event.stopPropagation();
$.ajax({
method: 'POST',
url: $(this).attr('action'),
dataType: 'json',
data: $(this).serialize(),
beforeSend: function() {
$(self.addonsLoginButtonSelector).show();
$("button.btn[type='submit']", self.addonsConnectForm).hide();
}
}).done(function (response) {
var responseCode = response.success;
var responseMsg = response.message;
if (responseCode === 1) {
location.reload();
} else {
$.growl.error({message: responseMsg});
$(self.addonsLoginButtonSelector).hide();
$("button.btn[type='submit']", self.addonsConnectForm).fadeIn();
}
});
});
};
this.initAddModuleAction = function () {
var addModuleButton = $(this.addonsImportModalBtnSelector);
addModuleButton.attr('data-toggle', 'modal');
addModuleButton.attr('data-target', this.dropZoneModalSelector);
};
this.initDropzone = function () {
var self = this;
var body = $('body');
var dropzone = $('.dropzone');
// Reset modal when click on Retry in case of failure
body.on('click', this.moduleImportFailureRetrySelector, function() {
$(self.moduleImportSuccessSelector + ', ' + self.moduleImportFailureSelector + ', ' + self.moduleImportProcessingSelector).fadeOut(function() {
// Added timeout for a better render of animation and avoid to have displayed at the same time
setTimeout(function() {
$(self.moduleImportStartSelector).fadeIn(function() {
$(self.moduleImportFailureMsgDetailsSelector).hide();
$(self.moduleImportSuccessConfigureBtnSelector).hide();
dropzone.removeAttr('style');
});
}, 550);
});
});
// Reinit modal on exit, but check if not already processing something
body.on('hidden.bs.modal', this.dropZoneModalSelector, function () {
$(self.moduleImportSuccessSelector + ', ' + self.moduleImportFailureSelector).hide();
$(self.moduleImportStartSelector).show();
dropzone.removeAttr('style');
$(self.moduleImportFailureMsgDetailsSelector).hide();
$(self.moduleImportSuccessConfigureBtnSelector).hide();
$(self.dropZoneModalFooterSelector).html('');
$(self.moduleImportConfirmSelector).hide();
});
// Change the way Dropzone.js lib handle file input trigger
body.on(
'click', '.dropzone:not('+this.moduleImportSelectFileManualSelector+', '+this.moduleImportSuccessConfigureBtnSelector+')',
function(event, manual_select) {
// if click comes from .module-import-start-select-manual, stop everything
if (typeof manual_select == "undefined") {
event.stopPropagation();
event.preventDefault();
}
}
);
body.on('click', this.moduleImportSelectFileManualSelector, function(event) {
event.stopPropagation();
event.preventDefault();
// Trigger click on hidden file input, and pass extra data to .dropzone click handler fro it to notice it comes from here
$('.dz-hidden-input').trigger('click', ["manual_select"]);
});
// Handle modal closure
body.on('click', this.moduleImportModalCloseBtn, function() {
if (self.isUploadStarted === true) {
// TODO: Display tooltip saying you can't escape at this stage
} else {
$(self.dropZoneModalSelector).modal('hide');
}
});
// Fix issue on click configure button
body.on('click', this.moduleImportSuccessConfigureBtnSelector, function(event) {
event.stopPropagation();
event.preventDefault();
window.location = $(this).attr('href');
});
// Open failure message details box
body.on('click', this.moduleImportFailureDetailsBtnSelector, function() {
$(self.moduleImportFailureMsgDetailsSelector).slideDown();
});
// @see: dropzone.js
var dropzoneOptions = {
url: moduleURLs.moduleImport,
acceptedFiles: '.zip, .tar',
// The name that will be used to transfer the file
paramName: 'file_uploaded',
maxFilesize: 50, // can't be greater than 50Mb because it's an addons limitation
uploadMultiple: false,
addRemoveLinks: true,
dictDefaultMessage: '',
hiddenInputContainer: self.dropZoneImportZoneSelector,
timeout:0, // add unlimited timeout. Otherwise dropzone timeout is 30 seconds and if a module is long to install, it is not possible to install the module.
addedfile: function() {
self.animateStartUpload();
},
processing: function () {
// Leave it empty since we don't require anything while processing upload
},
error: function (file, message) {
self.displayOnUploadError(message);
},
complete: function (file) {
if (file.status !== 'error') {
var responseObject = jQuery.parseJSON(file.xhr.response);
if (typeof responseObject.is_configurable === 'undefined') responseObject.is_configurable = null;
if (typeof responseObject.module_name === 'undefined') responseObject.module_name = null;
self.displayOnUploadDone(responseObject);
}
// State that we have finish the process to unlock some actions
self.isUploadStarted = false;
}
};
dropzone.dropzone($.extend(dropzoneOptions));
this.animateStartUpload = function() {
// State that we start module upload
self.isUploadStarted = true;
$(self.moduleImportStartSelector).hide(0);
dropzone.css('border', 'none');
$(self.moduleImportProcessingSelector).fadeIn();
};
this.animateEndUpload = function(callback) {
$(self.moduleImportProcessingSelector).finish().fadeOut(callback);
};
/**
* Method to call for upload modal, when the ajax call went well.
*
* @param object result containing the server response
*/
this.displayOnUploadDone = function(result) {
var self = this;
self.animateEndUpload(function() {
if (result.status === true) {
if (result.is_configurable === true) {
var configureLink = moduleURLs.configurationPage.replace('1', result.module_name);
$(self.moduleImportSuccessConfigureBtnSelector).attr('href', configureLink);
$(self.moduleImportSuccessConfigureBtnSelector).show();
}
$(self.moduleImportSuccessSelector).fadeIn();
} else if (typeof result.confirmation_subject !== 'undefined') {
self.displayPrestaTrustStep(result);
} else {
$(self.moduleImportFailureMsgDetailsSelector).html(result.msg);
$(self.moduleImportFailureSelector).fadeIn();
}
});
};
/**
* Method to call for upload modal, when the ajax call went wrong or when the action requested could not
* succeed for some reason.
*
* @param string message explaining the error.
*/
this.displayOnUploadError = function(message) {
self.animateEndUpload(function() {
$(self.moduleImportFailureMsgDetailsSelector).html(message);
$(self.moduleImportFailureSelector).fadeIn();
});
};
/**
* If PrestaTrust needs to be confirmed, we ask for the confirmation modal content and we display it in the
* currently displayed one. We also generate the ajax call to trigger once we confirm we want to install
* the module.
*
* @param Previous server response result
*/
this.displayPrestaTrustStep = function (result) {
var self = this;
var modal = module_card_controller.replacePrestaTrustPlaceholders(result);
var moduleName = result.module.attributes.name;
$(this.moduleImportConfirmSelector).html(modal.find('.modal-body').html()).fadeIn();
$(this.dropZoneModalFooterSelector).html(modal.find('.modal-footer').html()).fadeIn();
$(this.dropZoneModalFooterSelector).find(".pstrust-install").off('click').on('click', function() {
$(self.moduleImportConfirmSelector).hide();
$(self.dropZoneModalFooterSelector).html('');
self.animateStartUpload();
// Install ajax call
$.post(result.module.attributes.urls.install, { 'actionParams[confirmPrestaTrust]': "1"})
.done(function(data) {
self.displayOnUploadDone(data[moduleName]);
})
.fail(function(data) {
self.displayOnUploadError(data[moduleName]);
})
.always(function() {
self.isUploadStarted = false;
});
});
};
};
this.getBulkCheckboxesSelector = function () {
return this.currentDisplay == 'grid'
? this.bulkActionCheckboxGridSelector
: this.bulkActionCheckboxListSelector;
};
this.getBulkCheckboxesCheckedSelector = function () {
return this.currentDisplay == 'grid'
? this.checkedBulkActionGridSelector
: this.checkedBulkActionListSelector;
};
this.loadVariables = function () {
this.initCurrentDisplay();
};
this.getModuleItemSelector = function () {
return this.currentDisplay == 'grid'
? this.moduleItemGridSelector
: this.moduleItemListSelector;
};
/**
* Get the module notifications count and displays it as a badge on the notification tab
* @return void
*/
this.getNotificationsCount = function () {
var urlToCall = moduleURLs.notificationsCount;
$.getJSON(
urlToCall,
this.updateNotificationsCount
).fail(function() {
console.error('Could not retrieve module notifications count.');
});
};
this.updateNotificationsCount = function(badge) {
var destinationTabs = {
'to_configure': $("#subtab-AdminModulesNotifications"),
'to_update': $("#subtab-AdminModulesUpdates"),
};
for (var key in destinationTabs) {
if (destinationTabs[key].length === 0) {
continue;
}
destinationTabs[key].find('.notification-counter').text(badge[key]);
};
};
this.initAddonsSearch = function () {
var self = this;
$('body').on('click', this.addonItemGridSelector+', '+this.addonItemListSelector, function () {
var searchQuery = '';
if (self.currentTagsList.length) {
searchQuery = encodeURIComponent(self.currentTagsList.join(' '));
}
var hrefUrl = self.baseAddonsUrl+'search.php?search_query='+searchQuery;
window.open(hrefUrl, '_blank');
});
};
this.initCategoriesGrid = function () {
if (typeof refMenu === 'undefined') var refMenu = null;
var self = this;
$('body').on('click', this.categoryGridItemSelector, function (event) {
event.stopPropagation();
event.preventDefault();
var refCategory = $(this).attr('data-category-ref');
// In case we have some tags we need to reset it !
if (self.currentTagsList.length) {
self.pstaggerInput.resetTags(false);
self.currentTagsList = [];
}
var menuCategoryToTrigger = $(self.categoryItemSelector+'[data-category-ref="' + refCategory + '"]');
if (!menuCategoryToTrigger.length) {
console.warn('No category with ref ('+refMenu+') seems to exist!');
return false;
}
// Hide current category grid
if (self.isCategoryGridDisplayed === true) {
$(self.categoryGridSelector).fadeOut();
self.isCategoryGridDisplayed = false;
}
// Trigger click on right category
$(self.categoryItemSelector+'[data-category-ref="'+refCategory+'"]').click();
});
};
this.initCurrentDisplay = function() {
if (this.currentDisplay === '') {
this.currentDisplay = 'list';
} else {
this.currentDisplay = 'grid';
}
}
this.initSortingDropdown = function () {
var self = this;
self.currentSorting = $(this.moduleSortingDropdownSelector).find(':checked').attr('value');
$('body').on('change', this.moduleSortingDropdownSelector, function() {
self.currentSorting = $(this).find(':checked').attr('value');
self.updateModuleVisibility();
});
};
this.doBulkAction = function(requestedBulkAction) {
// This object is used to check if requested bulkAction is available and give proper
// url segment to be called for it
var forceDeletion = $('#force_bulk_deletion').prop('checked');
var bulkActionToUrl = {
'bulk-uninstall': 'uninstall',
'bulk-disable': 'disable',
'bulk-enable': 'enable',
'bulk-disable-mobile': 'disable_mobile',
'bulk-enable-mobile': 'enable_mobile',
'bulk-reset': 'reset'
};
// Note no grid selector used yet since we do not needed it at dev time
// Maybe useful to implement this kind of things later if intended to
// use this functionality elsewhere but "manage my module" section
if (typeof bulkActionToUrl[requestedBulkAction] === "undefined") {
$.growl.error({message: translate_javascripts['Bulk Action - Request not found'].replace('[1]', requestedBulkAction)});
return false;
}
// Loop over all checked bulk checkboxes
var bulkActionSelectedSelector = this.getBulkCheckboxesCheckedSelector();
if ($(bulkActionSelectedSelector).length > 0) {
var bulkModulesTechNames = [];
$(bulkActionSelectedSelector).each(function () {
var moduleTechName = $(this).attr('data-tech-name');
bulkModulesTechNames.push({
techName: moduleTechName,
actionMenuObj: $(this).parent().next()
});
});
$.each(bulkModulesTechNames, function (index, data) {
var actionMenuObj = data.actionMenuObj;
var moduleTechName = data.techName;
var urlActionSegment = bulkActionToUrl[requestedBulkAction];
if (typeof module_card_controller !== 'undefined') {
// We use jQuery to get the specific link for this action. If found, we send it.
var urlElement = $(module_card_controller.moduleActionMenuLinkSelector + urlActionSegment, actionMenuObj);
if (urlElement.length > 0) {
module_card_controller.requestToController(urlActionSegment, urlElement, forceDeletion);
} else {
$.growl.error({message: translate_javascripts["Bulk Action - Request not available for module"]
.replace('[1]', urlActionSegment)
.replace('[2]', moduleTechName)});
}
}
});
} else {
console.warn(translate_javascripts['Bulk Action - One module minimum']);
return false;
}
};
this.initActionButtons = function () {
$('body').on('click', this.moduleInstallBtnSelector, function(event) {
var $this = $(this);
var $next = $($this.next());
event.preventDefault();
$this.hide();
$next.show();
$.ajax({
url: $this.attr('data-url'),
dataType: 'json'
}).done(function () {
$next.fadeOut();
});
});
// "Upgrade All" button handler
var that = this;
$('body').on('click', this.upgradeAllSource, function(event) {
event.preventDefault();
$(that.upgradeAllTargets).click();
});
};
this.initCategorySelect = function () {
var self = this;
var body = $('body');
body.on('click', this.categoryItemSelector, function () {
// Get data from li DOM input
self.currentRefCategory = $(this).attr('data-category-ref').toLowerCase();
var categorySelectedDisplayName = $(this).attr('data-category-display-name');
// Change dropdown label to set it to the current category's displayname
$(self.categorySelectorLabelSelector).text(categorySelectedDisplayName);
$(self.categoryResetBtnSelector).show();
// Do Search on categoryRef
self.updateModuleVisibility();
});
body.on('click', this.categoryResetBtnSelector, function () {
var rawText = $(self.categorySelector).attr('aria-labelledby');
var upperFirstLetter = rawText.charAt(0).toUpperCase();
var removedFirstLetter = rawText.slice(1);
var originalText = upperFirstLetter + removedFirstLetter;
$(self.categorySelectorLabelSelector).text(originalText);
$(this).hide();
self.currentRefCategory = null;
self.updateModuleVisibility();
});
};
this.updateTotalResults = function() {
// If there are some shortlist: each shortlist count the modules on the next container.
var $shortLists = $('.module-short-list');
if ($shortLists.length > 0) {
$shortLists.each(function() {
var $this = $(this);
updateText(
$this.find('.module-search-result-wording'),
$this.next('.modules-list').find('.module-item').length
);
});
// If there is no shortlist: the wording directly update from the only module container.
} else {
var modulesCount = $('.modules-list').find('.module-item').length;
updateText(
$('.module-search-result-wording'),
modulesCount
);
$(this.addonItemGridSelector).toggle(modulesCount !== (this.modulesList.length/2));
$(this.addonItemListSelector).toggle(modulesCount !== (this.modulesList.length/2));
if (modulesCount === 0) {
$('.module-addons-search-link').attr(
'href',
this.baseAddonsUrl
+ 'search.php?search_query='
+ encodeURIComponent(this.currentTagsList.join(' '))
);
}
}
function updateText(element, value) {
var explodedText = element.text().split(' ');
explodedText[0] = value;
element.text(explodedText.join(' '));
}
};
this.initSearchBlock = function() {
var self = this;
this.pstaggerInput = $('#module-search-bar').pstagger({
onTagsChanged: function(tagList) {
self.currentTagsList = tagList;
self.updateModuleVisibility();
},
onResetTags: function() {
self.currentTagsList = [];
self.updateModuleVisibility();
},
inputPlaceholder: translate_javascripts['Search - placeholder'],
closingCross: true,
context: self,
});
$('body').on('click', '.module-addons-search-link', function(event) {
event.preventDefault();
event.stopPropagation();
var href = $(this).attr('href');
window.open(href, '_blank');
});
};
/**
* Initialize display switching between List or Grid
*/
this.initSortingDisplaySwitch = function() {
var self = this;
$('body').on('click', '.module-sort-switch', function() {
var switchTo = $(this).attr('data-switch');
var isAlreadyDisplayed = $(this).hasClass('active-display');
if (typeof switchTo !== 'undefined' && isAlreadyDisplayed === false) {
self.switchSortingDisplayTo(switchTo);
self.currentDisplay = switchTo;
}
});
};
this.switchSortingDisplayTo = function (switchTo) {
if (switchTo == 'grid' || switchTo == 'list') {
$('.module-sort-switch').removeClass('module-sort-active');
$('#module-sort-'+switchTo).addClass('module-sort-active');
this.currentDisplay = switchTo;
this.updateModuleVisibility();
} else {
console.error('Can\'t switch to undefined display property "' + switchTo + '"');
}
};
};

View File

@@ -0,0 +1,249 @@
var module_card_controller = {};
$(document).ready(function () {
module_card_controller = new AdminModuleCard();
module_card_controller.init();
});
/**
* AdminModule card Controller.
* @constructor
*/
var AdminModuleCard = function () {
/* Selectors for module action links (uninstall, reset, etc...) to add a confirm popin */
this.moduleActionMenuLinkSelector = 'button.module_action_menu_';
this.moduleActionMenuInstallLinkSelector = 'button.module_action_menu_install';
this.moduleActionMenuEnableLinkSelector = 'button.module_action_menu_enable';
this.moduleActionMenuUninstallLinkSelector = 'button.module_action_menu_uninstall';
this.moduleActionMenuDisableLinkSelector = 'button.module_action_menu_disable';
this.moduleActionMenuEnableMobileLinkSelector = 'button.module_action_menu_enable_mobile';
this.moduleActionMenuDisableMobileLinkSelector = 'button.module_action_menu_disable_mobile';
this.moduleActionMenuResetLinkSelector = 'button.module_action_menu_reset';
this.moduleActionMenuUpdateLinkSelector = 'button.module_action_menu_upgrade';
this.moduleItemListSelector = '.module-item-list';
this.moduleItemGridSelector = '.module-item-grid';
this.moduleItemActionsSelector = '.module-actions';
/* Selectors only for modal buttons */
this.moduleActionModalDisableLinkSelector = 'a.module_action_modal_disable';
this.moduleActionModalResetLinkSelector = 'a.module_action_modal_reset';
this.moduleActionModalUninstallLinkSelector = 'a.module_action_modal_uninstall';
this.forceDeletionOption = '#force_deletion';
/**
* Initialize all listeners and bind everything
* @method init
* @memberof AdminModuleCard
*/
this.init = function () {
this.initActionButtons();
};
this.getModuleItemSelector = function () {
if ($(this.moduleItemListSelector).length) {
return this.moduleItemListSelector;
} else {
return this.moduleItemGridSelector;
}
};
this.confirmAction = function(action, element) {
var modal = $('#' + $(element).data('confirm_modal'));
if (modal.length != 1) {
return true;
}
modal.first().modal('show');
return false; // do not allow a.href to reload the page. The confirm modal dialog will do it async if needed.
};
/**
* Update the content of a modal asking a confirmation for PrestaTrust and open it
*
* @param {array} result containing module data
* @return {void}
*/
this.confirmPrestaTrust = function confirmPrestaTrust(result) {
var that = this;
var modal = this.replacePrestaTrustPlaceholders(result);
modal.find(".pstrust-install").off('click').on('click', function() {
// Find related form, update it and submit it
var install_button = $(that.moduleActionMenuInstallLinkSelector, '.module-item[data-tech-name="' + result.module.attributes.name + '"]');
var form = install_button.parent("form");
$('<input>').attr({
type: 'hidden',
value: '1',
name: 'actionParams[confirmPrestaTrust]'
}).appendTo(form);
install_button.click();
modal.modal('hide');
});
modal.modal();
};
this.replacePrestaTrustPlaceholders = function replacePrestaTrustPlaceholders(result) {
var modal = $("#modal-prestatrust");
var module = result.module.attributes;
if (result.confirmation_subject !== 'PrestaTrust' || !modal.length) {
return;
}
var alertClass = module.prestatrust.status ? 'success' : 'warning';
if (module.prestatrust.check_list.property) {
modal.find("#pstrust-btn-property-ok").show();
modal.find("#pstrust-btn-property-nok").hide();
} else {
modal.find("#pstrust-btn-property-ok").hide();
modal.find("#pstrust-btn-property-nok").show();
modal.find("#pstrust-buy").attr("href", module.url).toggle(module.url !== null);
}
modal.find("#pstrust-img").attr({src: module.img, alt: module.name});
modal.find("#pstrust-name").text(module.displayName);
modal.find("#pstrust-author").text(module.author);
modal.find("#pstrust-label").attr("class", "text-" + alertClass).text(module.prestatrust.status ? 'OK' : 'KO');
modal.find("#pstrust-message").attr("class", "alert alert-"+alertClass);
modal.find("#pstrust-message > p").text(module.prestatrust.message);
return modal;
}
this.dispatchPreEvent = function (action, element) {
var event = jQuery.Event('module_card_action_event');
$(element).trigger(event, [action]);
if (event.isPropagationStopped() !== false || event.isImmediatePropagationStopped() !== false) {
return false; // if all handlers have not been called, then stop propagation of the click event.
}
return (event.result !== false); // explicit false must be set from handlers to stop propagation of the click event.
};
this.initActionButtons = function () {
var _this = this;
$(document).on('click', this.forceDeletionOption, function () {
var btn = $(_this.moduleActionModalUninstallLinkSelector, $("div.module-item-list[data-tech-name='" + $(this).attr("data-tech-name") + "']"));
if($(this).prop('checked') === true) {
btn.attr('data-deletion', 'true');
}else {
btn.removeAttr('data-deletion');
}
});
$(document).on('click', this.moduleActionMenuInstallLinkSelector, function () {
if ($("#modal-prestatrust").length) {
$("#modal-prestatrust").modal('hide');
}
return _this.dispatchPreEvent('install', this) && _this.confirmAction('install', this) && _this.requestToController('install', $(this));
});
$(document).on('click', this.moduleActionMenuEnableLinkSelector, function () {
return _this.dispatchPreEvent('enable', this) && _this.confirmAction('enable', this) && _this.requestToController('enable', $(this));
});
$(document).on('click', this.moduleActionMenuUninstallLinkSelector, function () {
return _this.dispatchPreEvent('uninstall', this) && _this.confirmAction('uninstall', this) && _this.requestToController('uninstall', $(this));
});
$(document).on('click', this.moduleActionMenuDisableLinkSelector, function () {
return _this.dispatchPreEvent('disable', this) && _this.confirmAction('disable', this) && _this.requestToController('disable', $(this));
});
$(document).on('click', this.moduleActionMenuEnableMobileLinkSelector, function () {
return _this.dispatchPreEvent('enable_mobile', this) && _this.confirmAction('enable_mobile', this) && _this.requestToController('enable_mobile', $(this));
});
$(document).on('click', this.moduleActionMenuDisableMobileLinkSelector, function () {
return _this.dispatchPreEvent('disable_mobile', this) && _this.confirmAction('disable_mobile', this) && _this.requestToController('disable_mobile', $(this));
});
$(document).on('click', this.moduleActionMenuResetLinkSelector, function () {
return _this.dispatchPreEvent('reset', this) && _this.confirmAction('reset', this) && _this.requestToController('reset', $(this));
});
$(document).on('click', this.moduleActionMenuUpdateLinkSelector, function () {
return _this.dispatchPreEvent('update', this) && _this.confirmAction('update', this) && _this.requestToController('update', $(this));
});
$(document).on('click', this.moduleActionModalDisableLinkSelector, function () {
return _this.requestToController('disable', $(_this.moduleActionMenuDisableLinkSelector, $("div.module-item-list[data-tech-name='" + $(this).attr("data-tech-name") + "']")));
});
$(document).on('click', this.moduleActionModalResetLinkSelector, function () {
return _this.requestToController('reset', $(_this.moduleActionMenuResetLinkSelector, $("div.module-item-list[data-tech-name='" + $(this).attr("data-tech-name") + "']")));
});
$(document).on('click', this.moduleActionModalUninstallLinkSelector, function (e) {
$(e.target).parents('.modal').on('hidden.bs.modal', function(event) {
return _this.requestToController(
'uninstall',
$(
_this.moduleActionMenuUninstallLinkSelector,
$("div.module-item-list[data-tech-name='" + $(e.target).attr("data-tech-name") + "']")
),
$(e.target).attr("data-deletion")
);
}.bind(e));
});
};
this.requestToController = function (action, element, forceDeletion) {
var _this = this;
var jqElementObj = element.closest(this.moduleItemActionsSelector);
var form = element.closest("form");
var spinnerObj = $("<button class=\"btn-primary-reverse onclick unbind spinner \"></button>");
var url = "//" + window.location.host + form.attr("action");
var actionParams = form.serializeArray();
if (forceDeletion === "true" || forceDeletion === true) {
actionParams.push({name: "actionParams[deletion]", value: true});
}
$.ajax({
url: url,
dataType: 'json',
method: 'POST',
data: actionParams,
beforeSend: function () {
jqElementObj.hide();
jqElementObj.after(spinnerObj);
}
}).done(function (result) {
if (typeof result === undefined) {
$.growl.error({message: "No answer received from server"});
} else {
var moduleTechName = Object.keys(result)[0];
if (result[moduleTechName].status === false) {
if (typeof result[moduleTechName].confirmation_subject !== 'undefined') {
_this.confirmPrestaTrust(result[moduleTechName]);
}
$.growl.error({message: result[moduleTechName].msg});
} else {
$.growl.notice({message: result[moduleTechName].msg});
var alteredSelector = null;
var mainElement = null;
if (action == "uninstall") {
jqElementObj.fadeOut(function() {
alteredSelector = _this.getModuleItemSelector().replace('.', '');
mainElement = jqElementObj.parents('.' + alteredSelector).first();
mainElement.remove();
});
BOEvent.emitEvent("Module Uninstalled", "CustomEvent");
} else if (action == "disable") {
alteredSelector = _this.getModuleItemSelector().replace('.', '');
mainElement = jqElementObj.parents('.' + alteredSelector).first();
mainElement.addClass(alteredSelector + '-isNotActive');
mainElement.attr('data-active', '0');
BOEvent.emitEvent("Module Disabled", "CustomEvent");
} else if (action == "enable") {
alteredSelector = _this.getModuleItemSelector().replace('.', '');
mainElement = jqElementObj.parents('.' + alteredSelector).first();
mainElement.removeClass(alteredSelector + '-isNotActive');
mainElement.attr('data-active', '1');
BOEvent.emitEvent("Module Enabled", "CustomEvent");
}
jqElementObj.replaceWith(result[moduleTechName].action_menu_html);
}
}
}).always(function () {
jqElementObj.fadeIn();
spinnerObj.remove();
});
return false;
};
};

View File

@@ -0,0 +1,78 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
$(document).ready(function() {
/*
* Link action on the select list in the navigator toolbar. When change occurs, the page is refreshed (location.href redirection)
*/
$('select[name="paginator_select_page_limit"]').change(function() {
var url = $(this).attr('psurl').replace(/_limit/, $('option:selected', this).val());
window.location.href = url;
return false;
});
/*
* Input field changes management
*/
function checkInputPage(eventOrigin) {
var e = eventOrigin || event;
var char = e.type === 'keypress' ? String.fromCharCode(e.keyCode || e.which) : (e.clipboardData || window.clipboardData).getData('Text');
if (/[^\d]/gi.test(char)) {
return false;
}
}
$('input[name="paginator_jump_page"]').each(function() {
this.onkeypress = checkInputPage;
this.onpaste = checkInputPage;
$(this).on('keyup', function(e) {
var val = parseInt($(e.target).val());
if (e.which === 13) { // ENTER
e.preventDefault();
if (parseInt(val) > 0) {
var limit = $(e.target).attr('pslimit');
var url = $(this).attr('psurl').replace(/999999/, (val-1)*limit);
window.location.href = url;
return false;
}
}
var max = parseInt($(e.target).attr('psmax'));
if (val > max) {
$(this).val(max);
return false;
}
});
$(this).on('blur', function(e) {
var val = parseInt($(e.target).val());
if (parseInt(val) > 0) {
var limit = $(e.target).attr('pslimit');
var url = $(this).attr('psurl').replace(/999999/, (val-1)*limit);
window.location.href = url;
return false;
}
});
});
});

View File

@@ -0,0 +1,272 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
(function ( $ ) {
var config = null;
var validateKeyCode = 13;
var tagsList = [];
var fullTagsString = null;
var pstaggerInput = null;
var defaultConfig = {
/* Global css config */
wrapperClassAdditional: '',
/* Tags part */
tagsWrapperClassAdditional: '',
tagClassAdditional: '',
closingCrossClassAdditionnal: '',
/* Tag Input part */
tagInputWrapperClassAdditional: '',
tagInputClassAdditional: '',
/* Global configuration */
delimiter: ' ',
inputPlaceholder: 'Add tag ...',
closingCross: true,
context: null,
clearAllBtn: false,
clearAllIconClassAdditional: '',
clearAllSpanClassAdditional: '',
/* Callbacks */
onTagsChanged: null,
onResetTags: null,
};
var immutableConfig = {
/* Global css config */
wrapperClass: 'pstaggerWrapper',
/* Tags part */
tagsWrapperClass: 'pstaggerTagsWrapper',
tagClass: 'pstaggerTag',
/* Tag Input part */
tagInputWrapperClass: 'pstaggerAddTagWrapper',
tagInputClass: 'pstaggerAddTagInput',
clearAllIconClass: '',
clearAllSpanClass: 'pstaggerResetTagsBtn',
closingCrossClass: 'pstaggerClosingCross',
};
var bindValidationInputEvent = function() {
// Validate input whenever validateKeyCode is pressed
pstaggerInput.keypress(function(event) {
if (event.keyCode == validateKeyCode) {
tagsList = [];
processInput();
}
});
// If focusout of input, display tagsWrapper if not empty or leave input as is
pstaggerInput.focusout(function(event){
// Necessarry to avoid race condition when focusout input because we want to reset :-)
if ($('.' + immutableConfig.clearAllSpanClass + ':hover').length) {
return false;
}
// Only redisplay tags on focusOut if there's something in tagsList
if (pstaggerInput.val().length) {
tagsList = [];
processInput();
}
});
};
var processInput = function() {
var fullTagsStringRaw = pstaggerInput.val();
var tagsListRaw = fullTagsStringRaw.split(config.delimiter);
// Check that's not an empty input
if (fullTagsStringRaw.length) {
// Loop over each tags we got this round
for (var key in tagsListRaw) {
var tagRaw = tagsListRaw[key];
// No empty values
if (tagRaw === '') {
continue;
}
// Add tag into persistent list
tagsList.push(tagRaw);
}
var spanTagsHtml = '';
// Create HTML dom from list of tags we have
for (key in tagsList) {
var tag = tagsList[key];
spanTagsHtml += formatSpanTag(tag);
}
// Delete previous if any, then add recreated html content
$('.' + immutableConfig.tagsWrapperClass).empty().prepend(spanTagsHtml).css('display', 'block');
// Hide input until user click on tagify_tags_wrapper
$('.' + immutableConfig.tagInputWrapperClass).css('display', 'none');
} else {
$('.' + immutableConfig.tagsWrapperClass).css('display', 'none');
$('.' + immutableConfig.tagInputWrapperClass).css('display', 'block');
pstaggerInput.focus();
}
// Call the callback ! (if one)
if (config.onTagsChanged !== null) {
config.onTagsChanged.call(config.context, tagsList);
}
};
var formatSpanTag = function(tag) {
var spanTag = '<span class="' + immutableConfig.tagClass + ' ' + config.tagClassAdditional+'">' +
'<span>' +
$('<div/>').text(tag).html() +
'</span>';
// Add closingCross if set to true
if (config.closingCross === true) {
spanTag += '<a class="' + immutableConfig.closingCrossClass + ' ' + config.closingCrossClassAdditionnal+'" href="#">x</a>';
}
spanTag += '</span>';
return spanTag;
};
var constructTagInputForm = function() {
// First hide native input
config.originalInput.css('display', 'none');
var addClearBtnHtml = '';
// If reset button required add it following user decription
if (config.clearAllBtn === true) {
addClearBtnHtml += '<span class="' + immutableConfig.clearAllSpanClass + ' ' + config.clearAllSpanClassAdditional +'">' +
'<i class="' + immutableConfig.clearAllIconClass + ' ' + config.clearAllIconClassAdditional +'">clear</i>' +
'</span>';
// Bind the click on the reset icon
bindResetTagsEvent();
}
// Add Tagify form after it
var formHtml = '<div class="' + immutableConfig.wrapperClass + ' ' + config.wrapperClassAdditional +'">' +
addClearBtnHtml +
'<div class="' + immutableConfig.tagsWrapperClass + ' ' + config.tagsWrapperClassAdditional +'"></div>' +
'<div class="' + immutableConfig.tagInputWrapperClass + ' ' + config.tagInputWrapperClassAdditional +'">' +
'<input class="' + immutableConfig.tagInputClass + ' ' + config.tagInputClassAdditional +'">' +
'</div>' +
'</div>';
// Insert form after the originalInput
config.originalInput.after(formHtml);
// Save tagify input in our object
pstaggerInput = $('.' + immutableConfig.tagInputClass);
// Add placeholder on tagify's input
pstaggerInput.attr('placeholder', config.inputPlaceholder);
return true;
};
var bindFocusInputEvent = function() {
// Bind click on tagsWrapper to switch and focus on input
$('.' + immutableConfig.tagsWrapperClass).on('click', function(event) {
var clickedElementClasses = event.target.className;
// Regexp to check if not clicked on closingCross to avoid focusing input if so
var checkClosingCrossRegex = new RegExp(immutableConfig.closingCrossClass, 'g');
var closingCrossClicked = clickedElementClasses.match(checkClosingCrossRegex);
if ($('.' + immutableConfig.tagInputWrapperClass).is(':hidden') && closingCrossClicked === null) {
$('.' + immutableConfig.tagsWrapperClass).css('display', 'none');
$('.' + immutableConfig.tagInputWrapperClass).css('display', 'block');
pstaggerInput.focus();
}
});
};
var bindResetTagsEvent = function() {
// Use delegate since we bind it before we insert the html in the DOM
var _this = this;
$(document).delegate('.' + immutableConfig.clearAllSpanClass, 'click', function(){
resetTags(true);
});
};
var resetTags = function(withCallback) {
// Empty tags list and tagify input
tagsList = [];
pstaggerInput.val('');
$('.' + immutableConfig.tagsWrapperClass).css('display', 'none');
$('.' + immutableConfig.tagInputWrapperClass).css('display', 'block');
pstaggerInput.focus();
// Empty existing Tags
$('.' + immutableConfig.tagClass).remove();
// Call the callback if one !
if (config.onResetTags !== null && withCallback === true) {
config.onResetTags.call(config.context);
}
}
var bindClosingCrossEvent = function() {
$(document).delegate('.' + immutableConfig.closingCrossClass, 'click', function(event){
var thisTagWrapper = $(this).parent();
var clickedTagIndex = thisTagWrapper.index();
// Iterate through tags to reconstruct new pstaggerInput value
var newInputValue = reconstructInputValFromRemovedTag(clickedTagIndex);
// Apply new input value
pstaggerInput.val(newInputValue);
thisTagWrapper.remove();
tagsList = [];
processInput();
});
};
var reconstructInputValFromRemovedTag = function(clickedTagIndex) {
var finalStr = '';
$('.' + immutableConfig.tagClass).each(function(index, value) {
// If this is the tag we want to remove then continue else add to return string val
if (clickedTagIndex == $(this).index()) {
// jQuery.each() continue;
return true;
}
// Add to return value
finalStr += ' ' + $(this).children().first().text();
});
return finalStr;
};
var getTagsListOccurencesCount = function() {
var obj = {};
for (var i = 0, j = tagsList.length; i < j; i++) {
obj[tagsList[i]] = (obj[tagsList[i]] || 0) + 1;
}
return obj;
};
var setConfig = function(givenConfig, originalObject) {
var finalConfig = {};
// Loop on each default values, check if one given by user, if so -> override default
for (var property in defaultConfig) {
if (givenConfig.hasOwnProperty(property)) {
finalConfig[property] = givenConfig[property];
} else {
finalConfig[property] = defaultConfig[property];
}
}
finalConfig.originalInput = originalObject;
return finalConfig;
};
// jQuery extends function
$.fn.pstagger = function(_config) {
config = setConfig(_config, this);
constructTagInputForm();
bindValidationInputEvent();
bindFocusInputEvent();
bindClosingCrossEvent();
return {
'resetTags': resetTags,
};
};
}(jQuery));

View File

@@ -0,0 +1,438 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
var $ = window.$;
$(document).ready(function() {
var form = $('form#product_catalog_list');
/*
* Tree behavior: collapse/expand system and radio button change event.
*/
$('div#product_catalog_category_tree_filter').categorytree();
$('div#product_catalog_category_tree_filter div.radio > label > input:radio').change(function() {
if ($(this).is(':checked')) {
$('form#product_catalog_list input[name="filter_category"]').val($(this).val());
$('form#product_catalog_list').submit();
}
});
$('div#product_catalog_category_tree_filter ~ div button, div#product_catalog_category_tree_filter ul').on('click', function() {
categoryFilterButtons();
});
categoryFilterButtons();
/*
* Click on a column header ordering icon to change orderBy / orderWay (location.href redirection)
*/
$('[psorderby][psorderway]', form).click(function() {
var orderBy = $(this).attr('psorderby');
var orderWay = $(this).attr('psorderway');
productOrderTable(orderBy, orderWay);
});
/*
* Checkboxes behavior with bulk actions
*/
$('input:checkbox[name="bulk_action_selected_products[]"]', form).change(function() {
updateBulkMenu();
});
/*
* Filter columns inputs behavior
*/
$('tr.column-filters input:text, tr.column-filters select', form).on('change input', function() {
productCatalogFilterChanged = true;
updateFilterMenu();
});
/*
* Sortable case when ordered by position ASC
*/
$("body").on("mousedown", "tbody.sortable [data-uniturl] td.placeholder", function () {
var trParent = $(this).closest('tr');
trParent.find('input:checkbox[name="bulk_action_selected_products[]"]').attr("checked", true);
});
$('tbody.sortable', form).sortable({
placeholder: 'placeholder',
update: function(event, ui) {
var positionSpan = $('span.position', ui.item)[0];
$(positionSpan).css('color', 'red');
bulkProductEdition(event, 'sort');
}
});
/*
* Form submit pre action
*/
form.submit(function(e) {
e.preventDefault();
$('#filter_column_id_product', form).val($('#filter_column_id_product', form).attr('sql'));
$('#filter_column_price', form).val($('#filter_column_price', form).attr('sql'));
$('#filter_column_sav_quantity', form).val($('#filter_column_sav_quantity', form).attr('sql'));
productCatalogFilterChanged = false;
this.submit();
return false;
});
/*
* Send to SQL manager button on modal
*/
$('#catalog_sql_query_modal button[value="sql_manager"]').on('click', function() {
sendLastSqlQuery(createSqlQueryName());
});
updateBulkMenu();
updateFilterMenu();
/** create keyboard event for save & new */
jwerty.key('ctrl+P', function(e) {
e.preventDefault();
var url = $('form#product_catalog_list').attr('newproducturl');
window.location.href = url;
});
});
function productOrderTable(orderBy, orderWay) {
var form = $('form#product_catalog_list');
var url = form.attr('orderingurl').replace(/name/, orderBy).replace(/asc/, orderWay);
window.location.href = url;
}
function productOrderPrioritiesTable() {
window.location.href = $('form#product_catalog_list').attr('orderingurl');
}
function updateBulkMenu() {
var selectedCount = $('form#product_catalog_list input:checked[name="bulk_action_selected_products[]"][disabled!="disabled"]').length;
$('#product_bulk_menu').prop('disabled', (selectedCount === 0));
}
var productCatalogFilterChanged = false;
function updateFilterMenu() {
var columnFilters = $('#product_catalog_list').find('tr.column-filters');
var count = columnFilters.find('option:selected[value!=""]').length;
columnFilters.find('input[type="text"][sql!=""][sql], input[type="text"]:visible').each(function() {
if ($(this).val() !== '') {
count++;
}
});
var filtersNotUpdatedYet = (count === 0 && productCatalogFilterChanged === false);
$('button[name="products_filter_submit"]').prop('disabled', filtersNotUpdatedYet);
$('button[name="products_filter_reset"]').toggle(!filtersNotUpdatedYet);
}
function productCategoryFilterReset(div) {
$('#product_categories').categorytree('unselect');
$('#product_catalog_list input[name="filter_category"]').val('');
$('#product_catalog_list').submit();
}
function productCategoryFilterExpand(div, btn) {
$('#product_categories').categorytree('unfold');
}
function productCategoryFilterCollapse(div, btn) {
$('#product_categories').categorytree('fold');
}
function categoryFilterButtons() {
var catTree = $('#product_catalog_category_tree_filter');
var catTreeSiblingDivs = $('#product_catalog_category_tree_filter ~ div');
var catTreeList = catTree.find('ul ul');
catTreeSiblingDivs.find('button[name="product_catalog_category_tree_filter_collapse"]').toggle(!catTreeList.filter(':visible').length);
catTreeSiblingDivs.find('button[name="product_catalog_category_tree_filter_expand"]').toggle(!catTreeList.filter(':hidden').length);
catTreeSiblingDivs.find('button[name="product_catalog_category_tree_filter_reset"]').toggle(!catTree.find('ul input:checked').length);
}
function productColumnFilterReset(tr) {
$('input:text', tr).val('');
$('select option:selected', tr).prop('selected', false);
$('#filter_column_price', tr).attr('sql', '');
$('#filter_column_sav_quantity', tr).attr('sql', '');
$('#filter_column_id_product', tr).attr('sql', '');
$('#product_catalog_list').submit();
}
function bulkModalAction(allItems, postUrl, redirectUrl, action) {
var itemsCount = allItems.length;
var currentItemIdx = 0;
if (itemsCount < 1) {
return;
}
var targetModal = $('#catalog_' + action + '_modal');
targetModal.modal('show');
var details = targetModal.find('#catalog_' + action + '_progression .progress-details-text');
var progressBar = targetModal.find('#catalog_' + action + '_progression .progress-bar');
var failure = targetModal.find('#catalog_' + action + '_failure');
// re-init popup
details.html(details.attr('default-value'));
progressBar.css('width', '0%');
progressBar.find('span').html('');
progressBar.removeClass('progress-bar-danger');
progressBar.addClass('progress-bar-success');
failure.hide();
// call in ajax. Recursive with inner function
var bulkCall = function (items, successCallback, errorCallback) {
if (items.length === 0) {
return;
}
var item0 = $(items.shift()).val();
currentItemIdx++;
details.html(details.attr('default-value').replace(/\.\.\./, '') + ' (#' + item0 + ')');
$.ajax({
type: 'POST',
url: postUrl,
data: {bulk_action_selected_products: [item0]},
success: function (data, status) {
progressBar.css('width', (currentItemIdx * 100 / itemsCount) + '%');
progressBar.find('span').html(currentItemIdx + ' / ' + itemsCount);
if (items.length > 0) {
bulkCall(items, successCallback, errorCallback);
} else {
successCallback();
}
},
error: errorCallback,
dataType: 'json'
});
};
bulkCall(allItems.toArray(), function () {
window.location.href = redirectUrl;
}, function () {
progressBar.removeClass('progress-bar-success');
progressBar.addClass('progress-bar-danger');
failure.show();
window.location.href = redirectUrl;
});
}
function bulkProductAction(element, action) {
var form = $('#product_catalog_list');
var postUrl = '';
var redirectUrl = '';
var urlHandler = null;
var items = $('input:checked[name="bulk_action_selected_products[]"]', form);
if (items.length === 0) {
return false;
} else {
urlHandler = $(element).closest('[bulkurl]');
}
switch (action) {
case 'delete_all':
postUrl = urlHandler.attr('bulkurl').replace(/activate_all/, action);
redirectUrl = urlHandler.attr('redirecturl');
// Confirmation popup and callback...
$('#catalog_deletion_modal').modal('show');
$('#catalog_deletion_modal button[value="confirm"]').off('click');
$('#catalog_deletion_modal button[value="confirm"]').on('click', function () {
$('#catalog_deletion_modal').modal('hide');
return bulkModalAction(items, postUrl, redirectUrl, action);
});
return; // No break, but RETURN, to avoid code after switch block :)
case 'activate_all':
postUrl = urlHandler.attr('bulkurl');
redirectUrl = urlHandler.attr('redirecturl');
return bulkModalAction(items, postUrl, redirectUrl, action);
break;
case 'deactivate_all':
postUrl = urlHandler.attr('bulkurl').replace(/activate_all/, action);
redirectUrl = urlHandler.attr('redirecturl');
return bulkModalAction(items, postUrl, redirectUrl, action);
break;
case 'duplicate_all':
postUrl = urlHandler.attr('bulkurl').replace(/activate_all/, action);
redirectUrl = urlHandler.attr('redirecturl');
return bulkModalAction(items, postUrl, redirectUrl, action);
break;
// this case will brings to the next page
case 'edition_next':
redirectUrl = $(element).closest('[massediturl]').attr('redirecturlnextpage');
// no break !
// this case will post inline edition command
case 'edition':
var editionAction;
var bulkEditionSelector = '#bulk_edition_toolbar input:submit';
if ($(bulkEditionSelector).length > 0) {
editionAction = $(bulkEditionSelector).attr('editionaction');
} else {
editionAction = 'sort';
}
urlHandler = $('[massediturl]');
postUrl = urlHandler.attr('massediturl').replace(/sort/, editionAction);
if (redirectUrl === '') {
redirectUrl = urlHandler.attr('redirecturl');
}
break;
// unknown cases...
default:
return false;
}
if (postUrl !== '' && redirectUrl !== '') {
// save action URL for redirection and update to post to bulk action instead
// using form action URL allow to get route attributes and stay on the same page & ordering.
var redirectionInput = $('<input>')
.attr('type', 'hidden')
.attr('name', 'redirect_url').val(redirectUrl);
form.append($(redirectionInput));
form.attr('action', postUrl);
form.submit();
}
return false;
}
function unitProductAction(element, action) {
var form = $('form#product_catalog_list');
// save action URL for redirection and update to post to bulk action instead
// using form action URL allow to get route attributes and stay on the same page & ordering.
var urlHandler = $(element).closest('[data-uniturl]');
var redirectUrlHandler = $(element).closest('[redirecturl]');
var redirectionInput = $('<input>')
.attr('type', 'hidden')
.attr('name', 'redirect_url').val(redirectUrlHandler.attr('redirecturl'));
switch (action) {
case 'delete':
// Confirmation popup and callback...
$('#catalog_deletion_modal').modal('show');
$('#catalog_deletion_modal button[value="confirm"]').off('click');
$('#catalog_deletion_modal button[value="confirm"]').on('click', function () {
form.append($(redirectionInput));
var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action);
form.attr('action', url);
form.submit();
$('#catalog_deletion_modal').modal('hide');
});
return;
// Other cases, nothing to do, continue.
//default:
}
form.append($(redirectionInput));
var url = urlHandler.attr('data-uniturl').replace(/duplicate/, action);
form.attr('action', url);
form.submit();
}
function showBulkProductEdition(show) {
// Paginator does not have a next page link : we are on the last page!
if ($('a#pagination_next_url[href]').length === 0) {
$('#bulk_edition_save_next').prop('disabled', true).removeClass('btn-primary');
$('#bulk_edition_save_keep').attr('type', 'submit').addClass('btn-primary');
}
if (show) {
$('#bulk_edition_toolbar').show();
} else {
$('#bulk_edition_toolbar').hide();
}
}
function bulkProductEdition(element, action) {
var form = $('form#product_catalog_list');
switch (action) {
/*
case 'quantity_edition':
showBulkProductEdition(true);
$('input#bulk_action_select_all, input:checkbox[name="bulk_action_selected_products[]"]', form).prop('disabled', true);
i = 1;
$('td.product-sav-quantity', form).each(function() {
$quantity = $(this).attr('productquantityvalue');
$product_id = $(this).closest('tr[productid]').attr('productid');
$input = $('<input>').attr('type', 'text').attr('name', 'bulk_action_edit_quantity['+$product_id+']')
.attr('tabindex', i++)
.attr('onkeydown', 'if (event.keyCode == 13) return bulkProductAction(this, "edition_next"); if (event.keyCode == 27) return bulkProductEdition(this, "cancel");')
.val($quantity);
$(this).html($input);
});
$('#bulk_edition_toolbar input:submit').attr('tabindex', i++);
$('#bulk_edition_toolbar input:button').attr('tabindex', i++);
$('#bulk_edition_toolbar input:submit').attr('editionaction', action);
$('td.product-sav-quantity input', form).first().focus();
break;
*/
case 'sort':
showBulkProductEdition(true);
$('input#bulk_action_select_all, input:checkbox[name="bulk_action_selected_products[]"]', form).prop('disabled', true);
$('#bulk_edition_toolbar input:submit').attr('editionaction', action);
break;
case 'cancel':
// quantity inputs
$('td.product-sav-quantity', form).each(function() {
$(this).html($(this).attr('productquantityvalue'));
});
$('#bulk_edition_toolbar input:submit').removeAttr('editionaction');
showBulkProductEdition(false);
$('input#bulk_action_select_all, input:checkbox[name="bulk_action_selected_products[]"]', form).prop('disabled', false);
break;
}
}
function showLastSqlQuery() {
$('#catalog_sql_query_modal_content textarea[name="sql"]').val($('tbody[last_sql]').attr('last_sql'));
$('#catalog_sql_query_modal').modal('show');
}
function sendLastSqlQuery(name) {
$('#catalog_sql_query_modal_content textarea[name="sql"]').val($('tbody[last_sql]').attr('last_sql'));
$('#catalog_sql_query_modal_content input[name="name"]').val(name);
$('#catalog_sql_query_modal_content').submit();
}

View File

@@ -0,0 +1,44 @@
/**
* Default category management
*/
var defaultCategory = (function() {
var defaultCategoryForm = $('#form_step1_id_category_default');
return {
'init': function () {
/** Populate category tree with the default category **/
var defaultCategoryId = defaultCategoryForm.find('input:checked').val();
productCategoriesTags.checkDefaultCategory(defaultCategoryId);
/** Hide the default form, if javascript disabled it will be visible and so we
* still can select a default category using the form
*/
defaultCategoryForm.hide();
},
/**
* Check the radio bouton with the selected value
*/
'check': function(value) {
defaultCategoryForm.find('input[value="'+value+'"]').prop('checked', true);
},
'isChecked': function(value) {
return defaultCategoryForm.find('input[value="'+value+'"]').is(':checked');
},
/**
* When the category selected as a default is unselected
* The default category MUST be a selected category
*/
'reset': function() {
var firstInput = defaultCategoryForm.find('input:first-child');
firstInput.prop('checked', true);
var categoryId = firstInput.val();
productCategoriesTags.checkDefaultCategory(categoryId);
}
};
})();
BOEvent.on("Product Default category Management started", function initDefaultCategoryManagement() {
defaultCategory.init();
}, "Back office");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
/**
* Product categories Tags management
*/
var productCategoriesTags = (function () {
var defaultCategoryForm = $('#form_step1_id_category_default');
var categoriesForm = $('#form_step1_categories');
var tagsContainer = $('#ps_categoryTags');
return {
'init': function () {
selectedCategories = this.getTags();
selectedCategories.forEach(this.createTag);
// add tags management
this.manageTagsOnInput();
this.manageTagsOnTags();
// add default category management
this.checkDefaultCategory();
// add search box
this.initSearchBox();
},
'removeTag': function (categoryId) {
$('span[data-id^="' + categoryId + '"]').parent().remove();
return true;
},
'getTags': function () {
var categoriesForm = $('#form_step1_categories');
var inputs = categoriesForm.find('label > input[type=checkbox]:checked').toArray();
var tags = [];
var that = this;
inputs.forEach(function getLabels(input) {
var tree = that.getTree();
var tag = {
'name': input.parentNode.innerText,
'id': input.value,
};
tree.forEach(function getCategories(_category) {
if (_category.id == tag.id) {
tag.breadcrumb = _category.breadcrumb;
}
});
tags.push(tag);
});
return tags;
},
'manageTagsOnInput': function () {
var categoriesForm = $('#form_step1_categories');
var that = this;
categoriesForm.on('change', 'input[type=checkbox]', function (event) {
var input = $(this);
if (input.prop('checked') === false) {
that.removeTag($(this).val());
} else {
var tag = {
'name': input.parent().text(),
'id': input.val(),
'breadcrumb': ''
};
that.createTag(tag);
}
});
return true;
},
'manageTagsOnTags': function () {
var that = this;
tagsContainer.on('click', 'a.pstaggerClosingCross', function (event) {
event.preventDefault();
var id = $(this).data('id');
that.removeTag(id);
categoriesForm.find('input[value="' + id + '"].category').prop('checked', false);
tagsContainer.focus();
});
return true;
},
'checkDefaultCategory': function (categoryId) {
var categoriesForm = $('#form_step1_categories');
var selector = 'input[value="'+categoryId+'"].default-category';
categoriesForm.find(selector).prop('checked', true);
},
'getTree': function () {
var tree = JSON.parse($('#ps_categoryTree').html());
return tree;
},
'createTag': function (category) {
if (category.breadcrumb == '') {
var tree = this.getTree();
tree.forEach(function getCategories(_category) {
if (_category.id == category.id) {
category.breadcrumb = _category.breadcrumb;
}
});
}
var isTagExist = tagsContainer.find('span[data-id='+ category.id +']');
if(0 == isTagExist.length) {
tagsContainer.append('<span class="pstaggerTag">' +
'<span data-id="' + category.id + '" title="' + category.breadcrumb + '">' + category.name + '</span>' +
'<a class="pstaggerClosingCross" href="#" data-id="' + category.id + '">x</a>' +
'</span>')
;
var optionId = '#form_step1_id_category_default_' + category.id;
if (0 == $(optionId).length) {
defaultCategoryForm.append('<div class="radio">' +
'<label class="required">' +
'<input type="radio"' + 'id="form_step1_id_category_default_' + category.id + '" name="form[step1][id_category_default]" required="required" value="' + category.id + '">' +
category.name +'</label>' +
'</div>');
}
}
return true;
},
'getNameFromBreadcrumb': function (name) {
if (name.indexOf('&gt;') !== -1) {
return name.substring(name.lastIndexOf('&gt') + 4); // remove "&gt; "
}
return name;
},
'initSearchBox': function () {
var searchCategorySelector = '#ps-select-product-category';
var searchBox = $(searchCategorySelector);
var tree = this.getTree();
var tags = [];
var that = this;
let searchResultMsg = '';
tree.forEach(function buildTags(tagObject){
tags.push({
label: tagObject.breadcrumb,
value: tagObject.id
});
});
searchBox.autocomplete({
source: tags,
minChars: 2,
autoFill: true,
max:20,
matchContains: true,
mustMatch:false,
scroll:false,
focus: function(event, ui) {
event.preventDefault();
let $this = $(this);
$this.val(that.getNameFromBreadcrumb(ui.item.label));
searchResultMsg = $this.parent().find('[role=status]').text();
},
select: function(event, ui) {
event.preventDefault();
var label = ui.item.label;
var categoryName = that.getNameFromBreadcrumb(label);
var categoryId = ui.item.value;
that.createTag({
'name': categoryName,
'id': categoryId,
'breadcrumb': label
});
var categoriesForm = $('#form_step1_categories');
categoriesForm.find('input[value="' + categoryId + '"].category').prop('checked', true);
$(this).val('');
}
}).data('ui-autocomplete')._renderItem = function(ul, item) {
return $('<li>')
.data('ui-autocomplete-item', item)
.append('<a>'+item.label+'</a>')
.appendTo(ul);
};
searchBox.parent().find('[role=status]').on('DOMSubtreeModified', function () {
let $this = $(this);
if ($.isNumeric($this.text()) && searchResultMsg !== '' && searchBox.val() !== '') {
$this.text(searchResultMsg);
}
});
$('body').on('focusout', searchCategorySelector, function (event) {
var $searchInput = $(event.currentTarget);
if (0 === $searchInput.val().length ) {
$searchInput.parent().find('[role=status]').text('');
searchResultMsg = '';
}
});
}
};
})();
BOEvent.on("Product Categories Management started", function initTagsManagement() {
productCategoriesTags.init();
}, "Back office");

View File

@@ -0,0 +1,294 @@
/**
* Combination management
*/
var combinations = (function() {
var id_product = $('#form_id_product').val();
/**
* Remove a combination
* @param {object} elem - The clicked link
*/
function remove(elem) {
var combinationElem = $('#attribute_' + elem.attr('data'));
modalConfirmation.create(translate_javascripts['Are you sure to delete this?'], null, {
onContinue: function() {
var attributeId = elem.attr('data');
$.ajax({
type: 'DELETE',
data: {'attribute-ids': [attributeId]},
url: elem.attr('href'),
beforeSend: function() {
elem.attr('disabled', 'disabled');
$('#create-combinations, #apply-on-combinations, #submit, .btn-submit').attr('disabled', 'disabled');
},
success: function(response) {
refreshTotalCombinations(-1, 1);
combinationElem.remove();
showSuccessMessage(response.message);
displayFieldsManager.refresh();
},
error: function(response) {
showErrorMessage(jQuery.parseJSON(response.responseText).message);
},
complete: function() {
elem.removeAttr('disabled');
$('#create-combinations, #apply-on-combinations, #submit, .btn-submit').removeAttr('disabled');
supplierCombinations.refresh();
warehouseCombinations.refresh();
if ($('.js-combinations-list .combination').length <= 0) {
$('#combinations_thead').fadeOut();
}
}
});
}
}).show();
}
/**
* Update final price, regarding the impact on price in combinations table
* @param {jQuery} tableRow - Table row that contains the combination
*/
function updateFinalPrice(tableRow) {
if (!tableRow.is('tr')) {
throw new Error('Structure of table has changed, this function needs to be updated.');
}
var priceImpactInput = tableRow.find('.attribute_priceTE').first();
var finalPriceLabel = tableRow.find('.attribute-finalprice span');
var impactOnPrice = Tools.parseFloatFromString(priceImpactInput.val());
var previousImpactOnPrice = Tools.parseFloatFromString(priceImpactInput.attr('value'));
var currentFinalPrice = Tools.parseFloatFromString(finalPriceLabel.data('price'), true);
var finalPrice = currentFinalPrice - previousImpactOnPrice + impactOnPrice;
finalPriceLabel.html(Number(ps_round(finalPrice, 6)).toFixed(6));
}
/**
* Returns a reference to the form for a specific combination
* @param {String} attributeId
* @return {jQuery}
*/
function getCombinationForm(attributeId) {
return $('#combination_form_' + attributeId);
}
/**
* Returns a reference to the row of a specific combination
* @param {String} attributeId
* @return {jQuery}
*/
function getCombinationRow(attributeId) {
return $('#accordion_combinations #attribute_' + attributeId);
}
return {
'init': function() {
var showVariationsSelector = '#show_variations_selector input';
var productTypeSelector = $('#form_step1_type_product');
var combinationsListSelector = '#accordion_combinations .combination';
var combinationsList = $(combinationsListSelector);
if (combinationsList.length > 0) {
productTypeSelector.prop('disabled', true);
}
$(document)
// delete combination
.on('click', '#accordion_combinations .delete', function(e) {
e.preventDefault();
remove($(this));
})
// when typing a new quantity on the form, update it on the row
.on('keyup', 'input[id^="combination"][id$="_attribute_quantity"]', function() {
var attributeId = $(this).closest('.combination-form').attr('data');
var input = getCombinationRow(attributeId).find('.attribute-quantity input');
input.val($(this).val());
})
// when typing a new quantity on the row, update it on the form
.on('keyup', '.attribute-quantity input', function() {
var attributeId = $(this).closest('.combination').attr('data');
var input = getCombinationForm(attributeId).find('input[id^="combination"][id$="_attribute_quantity"]');
input.val($(this).val());
})
.on({
// when typing a new impact on price on the form, update it on the row
'keyup': function () {
var attributeId = $(this).closest('.combination-form').attr('data');
var input = getCombinationRow(attributeId).find('.attribute-price input');
input.val($(this).val());
},
// when impact on price on the form is changed, update final price
'change': function () {
var attributeId = $(this).closest('.combination-form').attr('data');
var input = getCombinationRow(attributeId).find('.attribute-price input');
input.val($(this).val());
updateFinalPrice($(input.parents('tr')[0]));
}
}, 'input[id^="combination"][id$="_attribute_price"]')
// when price impact is changed on the row, update it on the form
.on('change', '.attribute-price input', function() {
var attributeId = $(this).closest('.combination').attr('data');
var input = getCombinationForm(attributeId).find('input[id^="combination"][id$="_attribute_price"]');
input.val($(this).val());
updateFinalPrice($(this).parent().parent().parent());
})
// on change default attribute, update which combination is the new default
.on('click', 'input.attribute-default', function() {
var selectedCombination = $(this);
var combinationRadioButtons = $('input.attribute-default');
var attributeId = $(this).closest('.combination').attr('data');
combinationRadioButtons.each(function unselect(index) {
var combination = $(this);
if (combination.data('id') !== selectedCombination.data('id')) {
combination.prop("checked", false);
}
});
$('.attribute_default_checkbox').removeAttr('checked');
getCombinationForm(attributeId)
.find('input[id^="combination"][id$="_attribute_default"]')
.prop("checked", true);
})
// Combinations fields display management
.on('change', showVariationsSelector, function() {
displayFieldsManager.refresh();
combinationsList = $(combinationsListSelector);
if ($(this).val() === '0') {
//if combination(s) exists, alert user for deleting it
if (combinationsList.length > 0) {
modalConfirmation.create(translate_javascripts['Are you sure to disable variations ? they will all be deleted'], null, {
onCancel: function() {
$('#show_variations_selector input[value="1"]').prop('checked', true);
displayFieldsManager.refresh();
},
onContinue: function() {
$.ajax({
type: 'GET',
url: $('#accordion_combinations').attr('data-action-delete-all').replace(/\/\d+(?=\?.*)/, '/' + $('#form_id_product').val()),
success: function(response) {
combinationsList.remove();
displayFieldsManager.refresh();
},
error: function(response) {
showErrorMessage(jQuery.parseJSON(response.responseText).message);
}
});
// enable the top header selector
// we want to use a "Simple product" without any combinations
productTypeSelector.prop('disabled', false);
}
}).show();
} else {
// enable the top header selector if no combination(s) exists
productTypeSelector.prop('disabled', false);
}
} else {
// this means we have or we want to have combinations
// disable the product type selector
productTypeSelector.prop('disabled', true);
}
})
// open combination form
.on('click', '#accordion_combinations .btn-open', function(e) {
e.preventDefault();
var contentElem = $($(this).attr('href'));
/** create combinations navigation */
var navElem = contentElem.find('.nav');
var id_attribute = contentElem.attr('data');
var prevCombinationId = $('#accordion_combinations tr[data="' + id_attribute + '"]').prev().attr('data');
var nextCombinationId = $('#accordion_combinations tr[data="' + id_attribute + '"]').next().attr('data');
navElem.find('.prev, .next').hide();
if (prevCombinationId) {
navElem.find('.prev').attr('data', prevCombinationId).show();
}
if (nextCombinationId) {
navElem.find('.next').attr('data', nextCombinationId).show();
}
/** init combination tax include price */
priceCalculation.impactTaxInclude(contentElem.find('.attribute_priceTE'));
contentElem.insertBefore('#form-nav').removeClass('hide').show();
contentElem.find('.datepicker input[type="text"]').datetimepicker({
locale: iso_user,
format: 'YYYY-MM-DD'
});
function countSelectedProducts() {
return $('#combination_form_' + contentElem.attr('data') + ' .img-highlight').length;
}
var number = $('#combination_form_' + contentElem.attr('data') + ' .number-of-images'),
allProductCombination = $('#combination_form_' + contentElem.attr('data') + ' .product-combination-image').length;
number.text(countSelectedProducts() + '/' + allProductCombination);
$(document).on('click','.tabs .product-combination-image', function () {
number.text(countSelectedProducts() + '/' + allProductCombination);
});
/** Add title on product's combination image */
$(function() {
$('#combination_form_' + contentElem.attr('data')).find("img").each(function() {
title = $(this).attr('src').split('/').pop();
$(this).attr('title',title);
});
});
$('#form-nav, #form_content').hide();
})
// close combination form
.on('click', '#form .combination-form .btn-back', function(e) {
e.preventDefault();
$(this).closest('.combination-form').hide();
$('#form-nav, #form_content').show();
})
// switch combination form
.on('click', '#form .combination-form .nav a', function(e) {
e.preventDefault();
$('.combination-form').hide();
$('#accordion_combinations .combination[data="' + $(this).attr('data') + '"] .btn-open').click();
})
;
}
};
})();
BOEvent.on("Product Combinations Management started", function initCombinationsManagement() {
combinations.init();
}, "Back office");
/**
* Refresh bulk actions combination number after creating or deleting combinations
*
* @param {number} sign
* @param {number} number
*/
var refreshTotalCombinations = function (sign, number) {
var $bulkCombinationsTotal = $('#js-bulk-combinations-total');
var currentnumber = parseInt($bulkCombinationsTotal.text()) + (sign * number);
$bulkCombinationsTotal.text(currentnumber);
}

View File

@@ -0,0 +1,34 @@
/**
* Manufacturer management
*/
var manufacturer = (function() {
return {
'init': function() {
var addButton = $('#add_brand_button');
var resetButton = $('#reset_brand_product');
var manufacturerContent = $('#manufacturer-content');
var selectManufacturer = $('#form_step1_id_manufacturer');
/** Click event on the add button */
addButton.on('click', function(e) {
e.preventDefault();
manufacturerContent.removeClass('hide');
addButton.hide();
});
resetButton.on('click', function(e) {
e.preventDefault();
modalConfirmation.create(translate_javascripts['Are you sure to delete this?'], null, {
onContinue: function(){
manufacturerContent.addClass('hide');
selectManufacturer.val('').trigger('change');
addButton.show();
}
}).show();
});
}
};
})();
BOEvent.on("Product Manufacturer Management started", function initManufacturerManagement() {
manufacturer.init();
}, "Back office");

View File

@@ -0,0 +1,42 @@
/**
* Related product management
*/
var relatedProduct = (function() {
return {
'init': function() {
var addButton = $('#add-related-product-button');
var resetButton = $('#reset_related_product');
var relatedContent = $('#related-content');
var productItems = $('#form_step1_related_products-data');
var searchProductsBar = $('#form_step1_related_products');
addButton.on('click', function(e) {
e.preventDefault();
relatedContent.removeClass('hide');
addButton.hide();
});
resetButton.on('click', function(e) {
e.preventDefault();
modalConfirmation.create(translate_javascripts['Are you sure to delete this?'], null, {
onContinue: function onContinue(){
var items = productItems.find('li').toArray();
items.forEach(function removeItem(item) {
console.log(item);
item.remove();
});
searchProductsBar.val('');
relatedContent.addClass('hide');
addButton.show();
}
}).show();
});
}
};
})();
BOEvent.on("Product Related Management started", function initRelatedProductManagement() {
relatedProduct.init();
}, "Back office");

View File

@@ -0,0 +1,148 @@
/* ========================================================================
* Bootstrap: sidebar.js v0.1
* ========================================================================
* Copyright 2011-2014 Asyraf Abdul Rahman
* Licensed under MIT
* ======================================================================== */
(function ($) {
'use strict';
// SIDEBAR PUBLIC CLASS DEFINITION
// ================================
var Sidebar = function (element, options) {
this.$element = $(element);
this.options = $.extend({}, Sidebar.DEFAULTS, options);
this.transitioning = null;
if (this.options.parent) {
this.$parent = $(this.options.parent);
}
if (this.options.toggle) {
this.toggle();
}
};
Sidebar.DEFAULTS = {
toggle: true
};
Sidebar.prototype.show = function () {
if (this.transitioning || this.$element.hasClass('sidebar-open')) {
return;
}
var startEvent = $.Event('show.bs.sidebar');
this.$element.trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return;
}
this.$element
.addClass('sidebar-open');
this.transitioning = 1;
var complete = function () {
this.transitioning = 0;
this.$element.trigger('shown.bs.sidebar');
};
if(!$.support.transition) {
return complete.call(this);
}
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(400);
};
Sidebar.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('sidebar-open')) {
return;
}
var startEvent = $.Event('hide.bs.sidebar');
this.$element.trigger(startEvent);
if(startEvent.isDefaultPrevented()) {
return;
}
this.$element
.removeClass('sidebar-open');
this.transitioning = 1;
var complete = function () {
this.transitioning = 0;
this.$element
.trigger('hidden.bs.sidebar');
};
if (!$.support.transition) {
return complete.call(this);
}
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(400);
};
Sidebar.prototype.toggle = function () {
this[this.$element.hasClass('sidebar-open') ? 'hide' : 'show']();
};
var old = $.fn.sidebar;
$.fn.sidebar = function (option) {
return this.each(function (){
var $this = $(this);
var data = $this.data('bs.sidebar');
var options = $.extend({}, Sidebar.DEFAULTS, $this.data(), typeof options === 'object' && option);
if (!data && options.toggle && option === 'show') {
option = !option;
}
if (!data) {
$this.data('bs.sidebar', (data = new Sidebar(this, options)));
}
if (typeof option === 'string') {
data[option]();
}
});
};
$.fn.sidebar.Constructor = Sidebar;
$.fn.sidebar.noConflict = function () {
$.fn.sidebar = old;
return this;
};
$(document).on('click.bs.sidebar.data-api', '[data-toggle="sidebar"]', function (e) {
var $this = $(this), href;
var target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '');
var $target = $(target);
var data = $target.data('bs.sidebar');
var option = data ? 'toggle' : $this.data();
$target.sidebar(option);
});
$('html').on('click.bs.sidebar.autohide', function(event){
var $this = $(event.target);
var isButtonOrSidebar = $this.is('.sidebar, [data-toggle="sidebar"]') || $this.parents('.sidebar, [data-toggle="sidebar"]').length;
if (isButtonOrSidebar) {
return;
} else {
var $target = $('.sidebar');
$target.each(function(i, trgt) {
var $trgt = $(trgt);
if($trgt.data('bs.sidebar') && $trgt.hasClass('sidebar-open')) {
$trgt.sidebar('hide');
}
});
}
});
})(jQuery);

View File

@@ -0,0 +1,463 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Date.prototype.addDays = function(value) {
this.setDate(this.getDate() + value);
return this;
};
Date.prototype.addMonths = function(value) {
var date = this.getDate();
this.setMonth(this.getMonth() + value);
if (this.getDate() < date) {
this.setDate(0);
}
return this;
};
Date.prototype.addWeeks = function(value) {
this.addDays(value * 7);
return this;
};
Date.prototype.addYears = function(value) {
var month = this.getMonth();
this.setFullYear(this.getFullYear() + value);
if (month < this.getMonth()) {
this.setDate(0);
}
return this;
};
Date.parseDate = function(date, format) {
if (format === undefined)
format = 'Y-m-d';
var formatSeparator = format.match(/[.\/\-\s].*?/);
var formatParts = format.split(/\W+/);
var parts = date.split(formatSeparator);
var date = new Date();
if (parts.length === formatParts.length) {
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
for (var i=0; i<=formatParts.length; i++) {
switch(formatParts[i]) {
case 'dd':
case 'd':
case 'j':
date.setDate(parseInt(parts[i], 10)||1);
break;
case 'mm':
case 'm':
date.setMonth((parseInt(parts[i], 10)||1) - 1);
break;
case 'yy':
case 'y':
date.setFullYear(2000 + (parseInt(parts[i], 10)||1));
break;
case 'yyyy':
case 'Y':
date.setFullYear(parseInt(parts[i], 10)||1);
break;
}
}
}
return date;
};
Date.prototype.subDays = function(value) {
this.setDate(this.getDate() - value);
return this;
};
Date.prototype.subMonths = function(value) {
var date = this.getDate();
this.setMonth(this.getMonth() - value);
if (this.getDate() < date) {
this.setDate(0);
}
return this;
};
Date.prototype.subWeeks = function(value) {
this.subDays(value * 7);
return this;
};
Date.prototype.subYears = function(value) {
var month = this.getMonth();
this.setFullYear(this.getFullYear() - value);
if (month < this.getMonth()) {
this.setDate(0);
}
return this;
};
Date.prototype.format = function(format) {
if (format === undefined)
return this.toString();
var formatSeparator = format.match(/[.\/\-\s].*?/);
var formatParts = format.split(/\W+/);
var result = '';
for (var i=0; i<=formatParts.length; i++) {
switch(formatParts[i]) {
case 'd':
case 'j':
result += this.getDate() + formatSeparator;
break;
case 'dd':
result += (this.getDate() < 10 ? '0' : '')+this.getDate() + formatSeparator;
break;
case 'm':
result += (this.getMonth() + 1) + formatSeparator;
break;
case 'mm':
result += (this.getMonth() < 9 ? '0' : '')+(this.getMonth() + 1) + formatSeparator;
break;
case 'yy':
case 'y':
result += this.getFullYear() + formatSeparator;
break;
case 'yyyy':
case 'Y':
result += this.getFullYear() + formatSeparator;
break;
}
}
return result.slice(0, -1);
}
function updatePickerFromInput() {
datepickerStart.setStart($("#date-start").val());
datepickerStart.setEnd($("#date-end").val());
datepickerStart.update();
datepickerEnd.setStart($("#date-start").val());
datepickerEnd.setEnd($("#date-end").val());
datepickerEnd.update();
$('#date-start').trigger('change');
if ($('#datepicker-compare').attr("checked")) {
if ($('#compare-options').val() == 1)
setPreviousPeriod();
if ($('#compare-options').val() == 2)
setPreviousYear();
datepickerStart.setStartCompare($("#date-start-compare").val());
datepickerStart.setEndCompare($("#date-end-compare").val());
datepickerEnd.setStartCompare($("#date-start-compare").val());
datepickerEnd.setEndCompare($("#date-end-compare").val());
datepickerStart.setCompare(true);
datepickerEnd.setCompare(true);
}
}
function setDayPeriod() {
date = new Date();
$("#date-start").val(date.format($("#date-start").data('date-format')));
$("#date-end").val(date.format($("#date-end").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('day');
$('button[name="submitDateRange"]').click();
}
function setPreviousDayPeriod() {
date = new Date();
date = date.subDays(1);
$("#date-start").val(date.format($("#date-start").data('date-format')));
$("#date-end").val(date.format($("#date-end").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('prev-day');
$('button[name="submitDateRange"]').click();
}
function setMonthPeriod() {
date = new Date();
$("#date-end").val(date.format($("#date-end").data('date-format')));
date = new Date(date.setDate(1));
$("#date-start").val(date.format($("#date-start").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('month');
$('button[name="submitDateRange"]').click();
}
function setPreviousMonthPeriod() {
date = new Date();
date = new Date(date.getFullYear(), date.getMonth(), 0);
$("#date-end").val(date.format($("#date-end").data('date-format')));
date = new Date(date.setDate(1));
$("#date-start").val(date.format($("#date-start").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('prev-month');
$('button[name="submitDateRange"]').click();
}
function setYearPeriod() {
date = new Date();
$("#date-end").val(date.format($("#date-end").data('date-format')));
date = new Date(date.getFullYear(), 0, 1);
$("#date-start").val(date.format($("#date-start").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('year');
$('button[name="submitDateRange"]').click();
}
function setPreviousYearPeriod() {
date = new Date();
date = new Date(date.getFullYear(), 11, 31);
date = date.subYears(1);
$("#date-end").val(date.format($("#date-end").data('date-format')));
date = new Date(date.getFullYear(), 0, 1);
$("#date-start").val(date.format($("#date-start").data('date-format')));
$('#date-start').trigger('change');
updatePickerFromInput();
$('#datepicker-from-info').html($("#date-start").val());
$('#datepicker-to-info').html($("#date-end").val());
$('#preselectDateRange').val('prev-year');
$('button[name="submitDateRange"]').click();
}
function setPreviousPeriod() {
startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format')).subDays(1);
endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format')).subDays(1);
diff = endDate - startDate;
startDateCompare = new Date(startDate-diff);
$("#date-end-compare").val(startDate.format($("#date-end-compare").data('date-format')));
$("#date-start-compare").val(startDateCompare.format($("#date-start-compare").data('date-format')));
}
function setPreviousYear() {
startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format')).subYears(1);
endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format')).subYears(1);
$("#date-start-compare").val(startDate.format($("#date-start").data('date-format')));
$("#date-end-compare").val(endDate.format($("#date-start").data('date-format')));
}
$( document ).ready(function() {
//Instanciate datepickers
datepickerStart = $('.datepicker1').daterangepicker({
"dates": translated_dates,
"weekStart": 1,
"start": $("#date-start").val(),
"end": $("#date-end").val()
}).on('changeDate', function(ev){
if (ev.date.valueOf() >= datepickerEnd.date.valueOf()){
datepickerEnd.setValue(ev.date.setMonth(ev.date.getMonth()+1));
}
}).data('daterangepicker');
datepickerEnd = $('.datepicker2').daterangepicker({
"dates": translated_dates,
"weekStart": 1,
"start": $("#date-start").val(),
"end": $("#date-end").val()
}).on('changeDate', function(ev){
if (ev.date.valueOf() <= datepickerStart.date.valueOf()){
datepickerStart.setValue(ev.date.setMonth(ev.date.getMonth()-1));
}
}).data('daterangepicker');
//Set first date picker to month -1 if same month
startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format'));
endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format'));
if (startDate.getFullYear() == endDate.getFullYear() && startDate.getMonth() == endDate.getMonth())
datepickerStart.setValue(startDate.subMonths(1));
//Events binding
$("#date-start").focus(function() {
datepickerStart.setCompare(false);
datepickerEnd.setCompare(false);
$(".date-input").removeClass("input-selected");
$(this).addClass("input-selected");
});
$("#date-end").focus(function() {
datepickerStart.setCompare(false);
datepickerEnd.setCompare(false);
$(".date-input").removeClass("input-selected");
$(this).addClass("input-selected");
});
$("#date-start-compare").focus(function() {
datepickerStart.setCompare(true);
datepickerEnd.setCompare(true);
$('#compare-options').val(3);
$(".date-input").removeClass("input-selected");
$(this).addClass("input-selected");
});
$("#date-end-compare").focus(function() {
datepickerStart.setCompare(true);
datepickerEnd.setCompare(true);
$('#compare-options').val(3);
$(".date-input").removeClass("input-selected");
$(this).addClass("input-selected");
});
$('#datepicker-cancel').click(function() {
$('#datepicker').addClass('hide');
});
$('#datepicker').show(function() {
$('#date-start').focus();
$('#date-start').trigger('change');
});
$('#datepicker-compare').click(function() {
if ($(this).attr("checked")) {
$('#compare-options').trigger('change');
$('#form-date-body-compare').show();
$('#compare-options').prop('disabled', false);
} else {
datepickerStart.setStartCompare(null);
datepickerStart.setEndCompare(null);
datepickerEnd.setStartCompare(null);
datepickerEnd.setEndCompare(null);
$('#form-date-body-compare').hide();
$('#compare-options').prop('disabled', true);
$('#date-start').focus();
}
})
$('#compare-options').change(function() {
if (this.value == 1)
setPreviousPeriod();
if (this.value == 2)
setPreviousYear();
datepickerStart.setStartCompare($("#date-start-compare").val());
datepickerStart.setEndCompare($("#date-end-compare").val());
datepickerEnd.setStartCompare($("#date-start-compare").val());
datepickerEnd.setEndCompare($("#date-end-compare").val());
datepickerStart.setCompare(true);
datepickerEnd.setCompare(true);
if (this.value == 3)
$('#date-start-compare').focus();
});
if ($('#datepicker-compare').attr("checked"))
{
if ($("#date-start-compare").val().replace(/^\s+|\s+$/g, '').length == 0)
$('#compare-options').trigger('change');
datepickerStart.setStartCompare($("#date-start-compare").val());
datepickerStart.setEndCompare($("#date-end-compare").val());
datepickerEnd.setStartCompare($("#date-start-compare").val());
datepickerEnd.setEndCompare($("#date-end-compare").val());
datepickerStart.setCompare(true);
datepickerEnd.setCompare(true);
}
$('#datepickerExpand').on('click',function() {
if ($('#datepicker').hasClass('hide'))
{
$('#datepicker').removeClass('hide');
$('#date-start').focus();
}
else
$('#datepicker').addClass('hide');
});
$('.submitDateDay').on('click',function(e){
e.preventDefault;
setDayPeriod();
});
$('.submitDateMonth').on('click',function(e){
e.preventDefault;
setMonthPeriod()
});
$('.submitDateYear').on('click',function(e){
e.preventDefault;
setYearPeriod();
});
$('.submitDateDayPrev').on('click',function(e){
e.preventDefault;
setPreviousDayPeriod();
});
$('.submitDateMonthPrev').on('click',function(e){
e.preventDefault;
setPreviousMonthPeriod();
});
$('.submitDateYearPrev').on('click',function(e){
e.preventDefault;
setPreviousYearPeriod();
});
});

View File

@@ -0,0 +1,745 @@
/* =========================================================
* bootstrap-datepicker.js
* http://www.eyecon.ro/bootstrap-datepicker
* =========================================================
* Copyright 2012 Stefan Petre
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
//click action
!function( $ ) {
var click, switched, val, start, end, over, compare, startCompare, endCompare;
// Picker object
var DateRangePicker = function(element, options){
this.element = $(element);
compare = false;
if (typeof options.dates !== 'undefined'){
DPGlobal.dates = options.dates;
}
if (typeof options.start !== 'undefined'){
if (options.start.constructor === String){
start = DPGlobal.parseDate(options.start, DPGlobal.parseFormat('Y-m-d')).getTime();
} else if (options.start.constructor === Number){
start = options.start;
} else if (options.start.constructor === Date){
start = options.start.getTime();
}
}
if (typeof options.end !== 'undefined'){
if (options.end.constructor === String){
end = DPGlobal.parseDate(options.end, DPGlobal.parseFormat('Y-m-d')).getTime();
} else if (options.end.constructor === Number) {
end = options.end;
} else if (options.end.constructor === Date) {
end = options.end.getTime();
}
}
if (typeof options.compare !== 'undefined'){
compare = options.compare;
}
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'Y-m-d');
this.picker = $(DPGlobal.template).appendTo(this.element).show()
.on({
click: $.proxy(this.click, this),
mouseover: $.proxy(this.mouseover, this),
mouseout: $.proxy(this.mouseout, this)
});
this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
if (typeof this.minViewMode === 'string') {
switch (this.minViewMode) {
case 'months':
this.minViewMode = 1;
break;
case 'years':
this.minViewMode = 2;
break;
default:
this.minViewMode = 0;
break;
}
}
this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
if (typeof this.viewMode === 'string') {
switch (this.viewMode) {
case 'months':
this.viewMode = 1;
break;
case 'years':
this.viewMode = 2;
break;
default:
this.viewMode = 0;
break;
}
}
this.startViewMode = this.viewMode;
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
this.onRender = options.onRender;
this.fillDow();
this.fillMonths();
this.update();
this.showMode();
};
DateRangePicker.prototype = {
constructor: DateRangePicker,
show: function(e) {
this.picker.show();
if (e ) {
e.stopPropagation();
e.preventDefault();
}
var that = this;
$(document).on('mousedown', function(ev){
if ($(ev.target).closest('.daterangepicker').length === 0) {
that.hide();
}
});
this.element.trigger({
type: 'show',
date: this.date
});
},
set: function() {
var formated = DPGlobal.formatDate(this.date, this.format);
this.element.data('date', formated);
},
setCompare: function(value) {
compare = value;
this.updateRange();
},
setStart: function(date) {
if (date.constructor === String) {
start = DPGlobal.parseDate(date, DPGlobal.parseFormat('Y-m-d')).getTime();
} else if (date.constructor === Number){
start = date;
} else if (date.constructor === Date){
start = date.getTime();
}
},
setEnd: function(date) {
if (date.constructor === String){
end = DPGlobal.parseDate(date, DPGlobal.parseFormat('Y-m-d')).getTime();
} else if (date.constructor === Number){
end = date;
} else if (date.constructor === Date){
end = date.getTime();
}
},
setStartCompare: function(date) {
if (date === null){
startCompare = date;
}
else if (date.constructor === String){
startCompare = DPGlobal.parseDate(date, DPGlobal.parseFormat('Y-m-d')).getTime();
}
else if (date.constructor === Number){
startCompare = date;
}
else if (date.constructor === Date){
startCompare = date.getTime();
}
},
setEndCompare: function(date) {
if (date === null){
endCompare = date;
} else if (date.constructor === String){
endCompare = DPGlobal.parseDate(date, DPGlobal.parseFormat('Y-m-d')).getTime();
} else if (date.constructor === Number){
endCompare = date;
} else if (date.constructor === Date){
endCompare = date.getTime();
}
},
setValue: function(newDate) {
if (typeof newDate === 'string') {
this.date = DPGlobal.parseDate(newDate, this.format);
} else {
this.date = new Date(newDate);
}
this.set();
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
this.fill();
},
update: function(newDate){
this.date = DPGlobal.parseDate(
typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
this.format
);
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
this.fill();
},
fillDow: function(){
var dowCnt = this.weekStart;
var html = '<tr>';
while (dowCnt < this.weekStart + 7) {
html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
}
html += '</tr>';
this.picker.find('.daterangepicker-days thead').append(html);
},
fillMonths: function(){
var html = '';
var i = 0;
while (i < 12) {
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
}
this.picker.find('.daterangepicker-months td').append(html);
},
fill: function() {
var d = new Date(this.viewDate),
year = d.getFullYear(),
month = d.getMonth(),
currentDate = this.date.valueOf();
this.picker.find('.daterangepicker-days th:eq(1)')
.text(year+' / '+DPGlobal.dates.months[month]).append('&nbsp;<small><i class="icon-angle-down"></i><small>');
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
prevMonth.setDate(day);
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
var nextMonth = new Date(prevMonth);
nextMonth.setDate(nextMonth.getDate() + 42);
nextMonth = nextMonth.valueOf();
var html = [];
var clsName, prevY, prevM;
while(prevMonth.valueOf() < nextMonth) {
if (prevMonth.getDay() === this.weekStart) {
html.push('<tr>');
}
clsName = this.onRender(prevMonth);
prevY = prevMonth.getFullYear();
prevM = prevMonth.getMonth();
if ((prevM < month && prevY === year) || prevY < year) {
clsName += ' old';
} else if ((prevM > month && prevY === year) || prevY > year) {
clsName += ' new';
}
if (!clsName){
html.push('<td class="day" data-val="'+prevMonth.getTime()+'">' + prevMonth.getDate() + '</td>');
} else {
html.push('<td class="'+clsName+'"></td>');
}
if (prevMonth.getDay() === this.weekEnd) {
html.push('</tr>');
}
prevMonth.setDate(prevMonth.getDate()+1);
}
this.picker.find('.daterangepicker-days tbody').empty().append(html.join(''));
var currentYear = this.date.getFullYear();
var months = this.picker.find('.daterangepicker-months')
.find('th:eq(1)')
.text(year)
.end()
.find('span').removeClass('active');
if (currentYear === year) {
months.eq(this.date.getMonth()).addClass('active');
}
html = '';
year = parseInt(year/10, 10) * 10;
var yearCont = this.picker.find('.daterangepicker-years')
.find('th:eq(1)')
.text(year + '-' + (year + 9))
.end()
.find('td');
year -= 1;
for (var i = -1; i < 11; i++) {
html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
year += 1;
}
yearCont.html(html);
this.updateRange();
//click = 2;
},
click: function(e) {
e.stopPropagation();
e.preventDefault();
var target = $(e.target).closest('span, td, th');
if (target.length === 1) {
switch(target[0].nodeName.toLowerCase()) {
case 'th':
switch(target[0].className) {
case 'month-switch':
this.showMode(1);
break;
case 'prev':
case 'next':
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
this.viewDate,
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
);
this.date = new Date(this.viewDate);
this.element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
this.fill();
this.set();
break;
}
break;
case 'span':
if (target.is('.month')) {
var month = target.parent().find('span').index(target);
this.viewDate.setMonth(month);
} else {
var year = parseInt(target.text(), 10)||0;
this.viewDate.setFullYear(year);
}
if (this.viewMode !== 0) {
this.date = new Date(this.viewDate);
this.element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
}
this.showMode(-1);
this.fill();
this.set();
break;
case 'td':
//reset
if (target.is('.day') && !target.is('.disabled')){
// reset process for a new range
if (start && end) {
if (!compare) {
click = 2 ;
$(".range").removeClass('range');
$(".start-selected").removeClass("start-selected");
$(".end-selected").removeClass("end-selected");
}
}
if(click === 2) {
if (compare) {
startCompare = null;
endCompare = null;
}
else {
start = null;
end = null;
}
click = null;
switched = false;
if (compare) {
$("td.day").removeClass("start-selected-compare").removeClass("end-selected-compare");
$(".date-input").removeClass("input-selected").removeClass("input-complete");
$(".range-compare").removeClass("range-compare");
} else {
$("td.day").removeClass("start-selected").removeClass("end-selected");
$(".date-input").removeClass("input-selected").removeClass("input-complete");
$(".range").removeClass("range");
}
}
//define start with first click or switched one
if (!click || switched === true) {
if (compare) {
$(".start-selected-compare").removeClass("start-selected-compare");
target.addClass("start-selected-compare");
startCompare = target.data("val");
$("#date-start-compare").val(DPGlobal.formatDate(new Date(startCompare), DPGlobal.parseFormat('Y-m-d')));
} else {
$(".start-selected").removeClass("start-selected");
target.addClass("start-selected");
start = target.data("val");
$("#date-start").val(DPGlobal.formatDate(new Date(start), DPGlobal.parseFormat('Y-m-d')));
$('#date-start').trigger('change');
}
if(!switched) {click = 1;} else {click = 2;}
if(!switched) {
if (compare) {
$("#date-end-compare").val(null).focus().addClass("input-selected");
target.addClass("start-selected-compare").addClass("end-selected-compare");
} else {
$("#date-end").val(null).focus().addClass("input-selected");
target.addClass("start-selected").addClass("end-selected");
}
}
if (compare) {
$("#date-start-compare").removeClass("input-selected").addClass("input-complete");
}
else {
$("#date-start").removeClass("input-selected").addClass("input-complete");
}
}
//define end
else {
if (compare) {
$(".end-selected-compare").removeClass("end-selected-compare");
target.addClass("end-selected-compare");
endCompare = target.data("val");
$("#date-end-compare").val(DPGlobal.formatDate(new Date(endCompare), DPGlobal.parseFormat('Y-m-d')));
click = 2;
$("#date-end-compare").removeClass("input-selected").addClass("input-complete");
} else {
$(".end-selected").removeClass("end-selected");
target.addClass("end-selected");
end = target.data("val");
$("#date-end").val(DPGlobal.formatDate(new Date(end), DPGlobal.parseFormat('Y-m-d')));
click = 2;
$("#date-end").removeClass("input-selected").addClass("input-complete");
$('#date-end').trigger('change');
}
}
}
break;
}
}
},
updateRange: function() {
$("#datepicker .day").each(function(){
var date_val = parseInt($(this).data('val'),10);
if (end && start) {
if(date_val > start && date_val < end) {
$(this).addClass("range");
}
if(date_val === start) {
$(this).addClass("start-selected");
}
if(date_val === end) {
$(this).addClass("end-selected");
}
}
if (endCompare && startCompare) {
$(this).removeClass("range-compare").removeClass("start-selected-compare").removeClass("end-selected-compare");
if(date_val > startCompare && date_val < endCompare) {
$(this).addClass("range-compare");
}
if(date_val === startCompare) {
$(this).addClass("start-selected-compare");
}
if(date_val === endCompare) {
$(this).addClass("end-selected-compare");
}
} else {
$(this).removeClass("range-compare").removeClass("start-selected-compare").removeClass("end-selected-compare");
}
});
},
mouseoverRange: function(){
//range
$("#datepicker .day").each(function(){
var date_val = parseInt($(this).data('val'),10);
if (compare) {
if (!endCompare && date_val > startCompare && date_val < over) {
$(this).not(".old").not(".new").addClass("range-compare");
}
else if (!startCompare && date_val > over && date_val < endCompare) {
$(this).not(".old").not(".new").addClass("range-compare");
}
else if (startCompare && endCompare) {
$(this).addClass("range-compare");
}
}
else {
if (!end && date_val > start && date_val < over) {
$(this).not(".old").not(".new").addClass("range");
}
else if (!start && date_val > over && date_val < end) {
$(this).not(".old").not(".new").addClass("range");
}
}
});
},
mouseover: function(e){
//data-val from day overed
over = $(e.target).data("val");
//action when one of two dates has been set
if(click === 1 && over){
if (compare) {
$("#datepicker .range-compare").removeClass("range-compare");
if (startCompare && over < startCompare) {
endCompare = startCompare;
$("#date-end-compare").val(DPGlobal.formatDate(new Date(startCompare), DPGlobal.parseFormat('Y-m-d'))).removeClass("input-selected");
$("#date-start-compare").val(null).focus().addClass("input-selected");
$("#datepicker .start-selected-compare").removeClass("start-selected-compare").addClass("end-selected-compare");
startCompare = null;
switched = true;
}
else if (endCompare && over > endCompare) {
startCompare = endCompare;
$("#date-start-compare").val(DPGlobal.formatDate(new Date(endCompare), DPGlobal.parseFormat('Y-m-d'))).removeClass("input-selected");
$("#date-end-compare").val(null).focus().addClass("input-selected");
$("#datepicker .end-selected-compare").removeClass("end-selected-compare").addClass("start-selected-compare");
endCompare = null;
switched = false;
}
if (startCompare) {
$(".end-selected-compare").removeClass("end-selected-compare");
$(e.target).addClass("end-selected-compare");
}
else if (endCompare) {
$(".start-selected-compare").removeClass("start-selected-compare");
$(e.target).addClass("start-selected-compare");
}
}
else {
$("#datepicker .range").removeClass("range");
if (start && over < start) {
end = start;
$("#date-end").val(DPGlobal.formatDate(new Date(start), DPGlobal.parseFormat('Y-m-d'))).removeClass("input-selected");
$('#date-end').trigger('change');
$("#date-start").val(null).focus().addClass("input-selected");
$("#datepicker .start-selected").removeClass("start-selected").addClass("end-selected");
start = null;
switched = true;
}
else if (end && over > end) {
start = end;
$("#date-start").val(DPGlobal.formatDate(new Date(end), DPGlobal.parseFormat('Y-m-d'))).removeClass("input-selected");
$('#date-start').trigger('change');
$("#date-end").val(null).focus().addClass("input-selected");
$("#datepicker .end-selected").removeClass("end-selected").addClass("start-selected");
end = null;
switched = false;
}
if (start) {
$(".end-selected").removeClass("end-selected");
$(e.target).addClass("end-selected");
}
else if (end) {
$(".start-selected").removeClass("start-selected");
$(e.target).addClass("start-selected");
}
}
//switch
$(".date-input").removeClass("input-complete");
this.mouseoverRange();
}
},
mouseout: function(){
if (compare) {
if (!startCompare||!endCompare) {
$("#datepicker .range-compare").removeClass("range-compare");
}
if (!endCompare) {
$(".end-selected-compare").removeClass("end-selected-compare");
}
else if (!startCompare)
$(".start-selected-compare").removeClass("start-selected-compare");
}
else {
if (!start||!end) {
$("#datepicker .range").removeClass("range");
}
if (!end) {
$(".end-selected").removeClass("end-selected");
}
else if (!start) {
$(".start-selected").removeClass("start-selected");
}
}
},
mousedown: function(e){
e.stopPropagation();
e.preventDefault();
},
showMode: function(dir) {
if (dir)
this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
this.picker.find('>div').hide().filter('.daterangepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
}
};
$.fn.daterangepicker = function ( option, val ) {
return this.each(function () {
var $this = $(this),
data = $this.data('daterangepicker'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('daterangepicker', (data = new DateRangePicker(this, $.extend({}, $.fn.daterangepicker.defaults,options))));
}
if (typeof option === 'string') { data[option](val);}
});
};
$.fn.daterangepicker.defaults = {
onRender: function() {
return '';
}
};
$.fn.daterangepicker.Constructor = DateRangePicker;
var DPGlobal = {
modes: [
{
clsName: 'days',
navFnc: 'Month',
navStep: 1
},
{
clsName: 'months',
navFnc: 'FullYear',
navStep: 1
},
{
clsName: 'years',
navFnc: 'FullYear',
navStep: 10
}],
dates:{
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
isLeapYear: function (year) {
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
},
getDaysInMonth: function (year, month) {
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
},
parseFormat: function(format){
var separator = format.match(/[.\/\-\s].*?/),
parts = format.split(/\W+/);
if (!separator || !parts || parts.length === 0){
throw new Error("Invalid date format.");
}
return {separator: separator, parts: parts};
},
parseDate: function(date, format) {
var parts = date.split(format.separator),
date = new Date(),
val;
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
if (parts.length === format.parts.length) {
var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
val = parseInt(parts[i], 10)||1;
switch(format.parts[i]) {
case 'dd':
case 'd':
day = val;
date.setDate(val);
break;
case 'mm':
case 'm':
month = val - 1;
date.setMonth(val - 1);
break;
case 'yy':
case 'y':
year = 2000 + val;
date.setFullYear(2000 + val);
break;
case 'yyyy':
case 'Y':
year = val;
date.setFullYear(val);
break;
}
}
date = new Date(year, month, day, 0 ,0 ,0);
}
return date;
},
formatDate: function(date, format){
var val = {
d: date.getDate(),
m: date.getMonth() + 1,
yy: date.getFullYear().toString().substring(2),
y: date.getFullYear().toString().substring(2),
yyyy: date.getFullYear(),
Y: date.getFullYear()
};
val.d = (val.d < 10 ? '0' : '') + val.d;
val.m = (val.m < 10 ? '0' : '') + val.m;
var date = [];
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
date.push(val[format.parts[i]]);
}
return date.join(format.separator);
},
headTemplate: '<thead>'+
'<tr>'+
'<th class="prev"><i class="icon-angle-left"></i></th>'+
'<th colspan="5" class="month-switch"></th>'+
'<th class="next"><i class="icon-angle-right"</th>'+
'</tr>'+
'</thead>',
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
};
DPGlobal.template = '<div class="daterangepicker">'+
'<div class="daterangepicker-days">'+
'<table class=" table-condensed">'+
DPGlobal.headTemplate+
'<tbody></tbody>'+
'</table>'+
'</div>'+
'<div class="daterangepicker-months">'+
'<table class="table-condensed">'+
DPGlobal.headTemplate+
DPGlobal.contTemplate+
'</table>'+
'</div>'+
'<div class="daterangepicker-years">'+
'<table class="table-condensed">'+
DPGlobal.headTemplate+
DPGlobal.contTemplate+
'</table>'+
'</div>'+
'</div>';
}( window.jQuery );

View File

@@ -0,0 +1,355 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
$(function() {
var storage = false;
if (typeof(getStorageAvailable) !== 'undefined') {
storage = getStorageAvailable();
}
initHelp = function(){
$('#main').addClass('helpOpen');
//first time only
if( $('#help-container').length === 0) {
//add css
$('head').append('<link href="//help.prestashop.com/css/help.css" rel="stylesheet">');
//add container
$('#main').after('<div id="help-container"></div>');
}
//init help (it use a global javascript variable to get actual controller)
pushContent(help_class_name);
$('#help-container').on('click', '.popup', function(e){
e.preventDefault();
if (storage)
storage.setItem('helpOpen', false);
$('.toolbarBox a.btn-help').trigger('click');
var helpWindow = window.open("index.php?controller=" + help_class_name + "?token=" + token + "&ajax=1&action=OpenHelp", "helpWindow", "width=450, height=650, scrollbars=yes");
});
};
//init
$('.toolbarBox a.btn-help').on('click', function(e) {
e.preventDefault();
if( !$('#main').hasClass('helpOpen') && document.body.clientWidth > 1200) {
if (storage)
storage.setItem('helpOpen', true);
$('.toolbarBox a.btn-help i').removeClass('process-icon-help').addClass('process-icon-loading');
initHelp();
} else if(!$('#main').hasClass('helpOpen') && document.body.clientWidth < 1200){
var helpWindow = window.open("index.php?controller=" + help_class_name + "?token=" + token + "&ajax=1&action=OpenHelp", "helpWindow", "width=450, height=650, scrollbars=yes");
} else {
$('#main').removeClass('helpOpen');
$('#help-container').html('');
$('.toolbarBox a.btn-help i').removeClass('process-icon-close').addClass('process-icon-help');
if (storage)
storage.setItem('helpOpen', false);
}
});
// Help persistency
if (storage && storage.getItem('helpOpen') == "true") {
$('a.btn-help').trigger('click');
}
//switch home
var language = iso_user;
var home;
switch(language) {
case 'en':
home = '19726802';
break;
case 'fr':
home = '20840479';
break;
default:
language = 'en';
home = '19726802';
}
//feedback
var arr_feedback = {};
arr_feedback.page = 'page';
arr_feedback.helpful = 'helpful';
//toc
var toc = [];
var lang = [
['en','19726802'],
['fr','20840479']
];
// change help icon
function iconCloseHelp(){
$('.toolbarBox a.btn-help i').removeClass('process-icon-loading').addClass('process-icon-close');
}
//get content
function getHelp(pageController) {
var request = encodeURIComponent("getHelp=" + pageController + "&version="+ _PS_VERSION_ +"&language=" + iso_user);
var d = new $.Deferred();
$.ajax( {
url: "//help.prestashop.com/api/?request=" + request,
jsonp:"callback",
dataType:"jsonp",
success: function(data) {
if (isCleanHtml(data))
{
$('#help-container').html(data);
d.resolve();
}
}
});
return d.promise();
}
//update content
function pushContent(target) {
$('#help-container').removeClass('openHelpNav');
$('#help-container').html('');
//@todo: track event
getHelp(target)
.then(iconCloseHelp)
.then(initToc)
.then(initNavigation)
.then(initSearch)
.then(initFeedback);
}
//build navigation
function initNavigation() {
var d = new $.Deferred();
var request = encodeURIComponent("api/content/" + home + "/child?expand=page");
$.ajax( {
url: "//help.prestashop.com/api/?request=" + request,
jsonp: "callback",
dataType: "jsonp",
success: function(data) {
for (var i = 0 ; i < data.page.results.length ; i++){
if (isCleanHtml(data.page.results[i].id + data.page.results[i].title))
$("#help-container #main-nav").append('<a href="//help.prestashop.com/' + data.page.results[i].id + '?version='+ _PS_VERSION_ +'" data-target="' + data.page.results[i].id + '">' + data.page.results[i].title + '</a>');
}
$("#help-container #main-nav a").on('click',function(e){
e.preventDefault();
pushContent($(this).data('target'));
});
$('#help-container .open-menu').on('click', function(e){
e.preventDefault();
$('#help-container').addClass('openHelpNav');
});
$('#help-container .close-menu').on('click', function(e){
e.preventDefault();
$('#help-container').removeClass('openHelpNav');
});
d.resolve();
}
});
return d.promise();
}
//build toc getting children from home page recursively
function initToc() {
var getLinksByLang = function(item) {
var d = new $.Deferred();
var request = encodeURIComponent("api/content/" + item[1] + "/child/page?expand=children.page&limit=100");
$.ajax( {
url: "//help.prestashop.com/api/?request=" + request,
jsonp : "callback",
dataType:"jsonp",
success: function(data) {
toc[item[0]] = {
'title': 'Home ' + item[0],
'lang': item[0],
'id': item[1],
'children': []
};
data.results.map(function(page,j){
var children = [];
page.children.page.results.map(function(child,i) {
children[i] = {
'title': child.title,
'link': child._links.webui,
'id': child.id,
'lang' : item[0]
};
});
toc[item[0]].children[j] = {
'title' : page.title,
'link' : page._links.webui,
'id': page.id,
'children' : children,
'lang' : item[0]
};
});
d.resolve();
},
});
return d.promise();
};
return $.when.apply(null, lang.map(getLinksByLang)).then(function () {
//build mapping
var mapping = {};
$.each(toc[language].children,function(i,section){
mapping[section.link] = [section.id,section.title,section.lang];
if (typeof section.children !== 'undefined') {
$.each(section.children,function(i,section){
mapping[section.link] = [section.id,section.title,section.lang];
});
}
});
//remap links
$( "#help-container a[href^='/display/']" ).on('click', function(e){
e.preventDefault();
var href = $(this).attr('href');
var target = mapping[href][0];
pushContent(target);
});
$( "#help-container a[href^='/pages/viewpage.action?pageId=']" ).on('click', function(e){
e.preventDefault();
var pageId = $(this).attr('href').match(/\d+$/);
if (pageId) {
pushContent(pageId[0]);
}
});
// rewrite url ? -> "//help.prestashop.com/" + mapping[href][0] + '?version='+ _PS_VERSION_ +'&language=' + mapping[href][2];
//home link
$('#help-container a.home').attr('href', '//help.prestashop.com/'+toc[language].id+'?version='+ _PS_VERSION_).on('click',function(e){
e.preventDefault();
pushContent(toc[language].id);
});
//target _blank external link
$( "#help-container a[href^='http://']" ).attr( "href", function() {
$(this).attr('target','_blank').append('&nbsp;<i class="fa fa-external-link"></i>');
});
//add class anchor to link from table of content
$('#help-container .toc-indentation a').addClass('anchor');
});
}
//search
function initSearch() {
//replace tag from confluence search api
function strongify(str) {
return str.replace(/@@@hl@@@/g, '<strong>').replace(/@@@endhl@@@/g, '</strong>');
}
$("#help-container #search-box").on("submit",function(e) {
e.preventDefault();
$("#help-container #search-results").html('');
var searchUrl = encodeURIComponent("searchv3/1.0/search?where=PS16&type=page&queryString=");
var searchTerm = encodeURIComponent($('input[name="search"]').val());
$.ajax( {
url: "//help.prestashop.com/api/?request=" + searchUrl + searchTerm,
jsonp: "callback",
dataType: "jsonp",
success: function(data) {
if (data.results.length === 0) {
$("#search-results").addClass('hide');
}
for (var i = 0 ; i < data.results.length ; i++) {
if (isCleanHtml(data.results[i].id + data.results[i].title + data.results[i].bodyTextHighlights)) {
$("#search-results").removeClass('hide')
.append( '<div class="result-item"><i class="fa fa-file-o"></i> <a href="//help.prestashop.com/' + data.results[i].id + '?version='+ _PS_VERSION_ +'" data-target="' + data.results[i].id + '">' + strongify(data.results[i].title) + '</a><p>' + strongify(data.results[i].bodyTextHighlights) + '</p></div>');
}
}
$("#search-results a").on('click',function(e) {
e.preventDefault();
pushContent($(this).data('target'));
});
}
});
});
$('#help-container').on('click','.search',function(e) {
e.preventDefault();
$('#help-container #search-box').removeClass('hide');
$('#help-container .header-navigation').addClass('hide');
$('#search-box input[name=search]').focus();
});
$('#help-container').on('click','.close-search',function(){
$('#help-container #search-box').addClass('hide');
$('#help-container .header-navigation').removeClass('hide');
});
}
//feedback
function initFeedback() {
var arr_feedback = {
version:_PS_VERSION_,
controller: help_class_name,
language: iso_user,
helpful: null,
reason: null,
comment: null
};
$('#help-container .helpful-labels li').on('click', function(){
var percentageMap = {0:'Not at all', 25:'Not very', 50:'Somewhat', 75:'Very', 100:'Extremely'};
var percentage = parseInt($(this).data('percentage'));
arr_feedback.helpful = percentageMap[percentage];
$('#help-container .slider-cursor').removeClass('hide');
$('#help-container .helpful-labels li').removeClass('active');
$('#help-container .slider-cursor').css('left',percentage+'%');
$('#help-container .helpful-labels li').addClass('disabled').off();
$(this).removeClass('disabled').addClass('active');
if (percentage <= 25) {
$('#help-container .feedback-reason').show();
} else if (percentage > 25) {
submitFeedback(arr_feedback);
}
});
$('#help-container .feedback-reason .radio label').on('click', function() {
var reasonMap = {1:'Not related', 2:'Too complicated', 3:'Too much', 4:'Incorrect', 5:'Unclear', 6:'Incomplete'};
arr_feedback.reason = reasonMap[$('input[name=lowrating-reason]:checked').val()];
});
$('#help-container .feedback-submit').on('click', function(e) {
e.preventDefault();
arr_feedback.comment = $('textarea[name=feedback-detail]').val();
submitFeedback(arr_feedback);
});
}
function submitFeedback(arr_feedback) {
var feedback = '?';
var keys = Object.keys(arr_feedback);
for (var i = 0; i < keys.length; i++) {
if (i > 0){
feedback += '&';
}
feedback += keys[i] + '=' + arr_feedback[keys[i]];
}
$.ajax( {
url: "//help.prestashop.com/api/feedback/" + feedback,
dataType: 'jsonp',
jsonp: "callback",
success: function(){
$('#help-container #helpful-feedback').hide();
$('#help-container .thanks').removeClass('hide');
}
});
}
});

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,294 @@
/*
* jQuery File Upload Image Preview & Resize Plugin 1.3.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window, document, DataView, Blob, Uint8Array */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'load-image',
'load-image-meta',
'load-image-exif',
'load-image-ios',
'canvas-to-blob',
'./jquery.fileupload-process'
], factory);
} else {
// Browser globals:
factory(
window.jQuery,
window.loadImage
);
}
}(function ($, loadImage) {
'use strict';
// Prepend to the default processQueue:
$.blueimp.fileupload.prototype.options.processQueue.unshift(
{
action: 'loadImageMetaData',
disableImageHead: '@',
disableExif: '@',
disableExifThumbnail: '@',
disableExifSub: '@',
disableExifGps: '@',
disabled: '@disableImageMetaDataLoad'
},
{
action: 'loadImage',
// Use the action as prefix for the "@" options:
prefix: true,
fileTypes: '@',
maxFileSize: '@',
noRevoke: '@',
disabled: '@disableImageLoad'
},
{
action: 'resizeImage',
// Use "image" as prefix for the "@" options:
prefix: 'image',
maxWidth: '@',
maxHeight: '@',
minWidth: '@',
minHeight: '@',
crop: '@',
orientation: '@',
disabled: '@disableImageResize'
},
{
action: 'saveImage',
disabled: '@disableImageResize'
},
{
action: 'saveImageMetaData',
disabled: '@disableImageMetaDataSave'
},
{
action: 'resizeImage',
// Use "preview" as prefix for the "@" options:
prefix: 'preview',
maxWidth: '@',
maxHeight: '@',
minWidth: '@',
minHeight: '@',
crop: '@',
orientation: '@',
thumbnail: '@',
canvas: '@',
disabled: '@disableImagePreview'
},
{
action: 'setImage',
name: '@imagePreviewName',
disabled: '@disableImagePreview'
}
);
// The File Upload Resize plugin extends the fileupload widget
// with image resize functionality:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
options: {
// The regular expression for the types of images to load:
// matched against the file type:
loadImageFileTypes: /^image\/(gif|jpeg|png)$/,
// The maximum file size of images to load:
loadImageMaxFileSize: 10000000, // 10MB
// The maximum width of resized images:
imageMaxWidth: 1920,
// The maximum height of resized images:
imageMaxHeight: 1080,
// Defines the image orientation (1-8) or takes the orientation
// value from Exif data if set to true:
imageOrientation: false,
// Define if resized images should be cropped or only scaled:
imageCrop: false,
// Disable the resize image functionality by default:
disableImageResize: true,
// The maximum width of the preview images:
previewMaxWidth: 80,
// The maximum height of the preview images:
previewMaxHeight: 80,
// Defines the preview orientation (1-8) or takes the orientation
// value from Exif data if set to true:
previewOrientation: true,
// Create the preview using the Exif data thumbnail:
previewThumbnail: true,
// Define if preview images should be cropped or only scaled:
previewCrop: false,
// Define if preview images should be resized as canvas elements:
previewCanvas: true
},
processActions: {
// Loads the image given via data.files and data.index
// as img element, if the browser supports the File API.
// Accepts the options fileTypes (regular expression)
// and maxFileSize (integer) to limit the files to load:
loadImage: function (data, options) {
if (options.disabled) {
return data;
}
var that = this,
file = data.files[data.index],
dfd = $.Deferred();
if (($.type(options.maxFileSize) === 'number' &&
file.size > options.maxFileSize) ||
(options.fileTypes &&
!options.fileTypes.test(file.type)) ||
!loadImage(
file,
function (img) {
if (img.src) {
data.img = img;
}
dfd.resolveWith(that, [data]);
},
options
)) {
return data;
}
return dfd.promise();
},
// Resizes the image given as data.canvas or data.img
// and updates data.canvas or data.img with the resized image.
// Also stores the resized image as preview property.
// Accepts the options maxWidth, maxHeight, minWidth,
// minHeight, canvas and crop:
resizeImage: function (data, options) {
if (options.disabled || !(data.canvas || data.img)) {
return data;
}
options = $.extend({canvas: true}, options);
var that = this,
dfd = $.Deferred(),
img = (options.canvas && data.canvas) || data.img,
resolve = function (newImg) {
if (newImg && (newImg.width !== img.width ||
newImg.height !== img.height)) {
data[newImg.getContext ? 'canvas' : 'img'] = newImg;
}
data.preview = newImg;
dfd.resolveWith(that, [data]);
},
thumbnail;
if (data.exif) {
if (options.orientation === true) {
options.orientation = data.exif.get('Orientation');
}
if (options.thumbnail) {
thumbnail = data.exif.get('Thumbnail');
if (thumbnail) {
loadImage(thumbnail, resolve, options);
return dfd.promise();
}
}
}
if (img) {
resolve(loadImage.scale(img, options));
return dfd.promise();
}
return data;
},
// Saves the processed image given as data.canvas
// inplace at data.index of data.files:
saveImage: function (data, options) {
if (!data.canvas || options.disabled) {
return data;
}
var that = this,
file = data.files[data.index],
name = file.name,
dfd = $.Deferred(),
callback = function (blob) {
if (!blob.name) {
if (file.type === blob.type) {
blob.name = file.name;
} else if (file.name) {
blob.name = file.name.replace(
/\..+$/,
'.' + blob.type.substr(6)
);
}
}
// Store the created blob at the position
// of the original file in the files list:
data.files[data.index] = blob;
dfd.resolveWith(that, [data]);
};
// Use canvas.mozGetAsFile directly, to retain the filename, as
// Gecko doesn't support the filename option for FormData.append:
if (data.canvas.mozGetAsFile) {
callback(data.canvas.mozGetAsFile(
(/^image\/(jpeg|png)$/.test(file.type) && name) ||
((name && name.replace(/\..+$/, '')) ||
'blob') + '.png',
file.type
));
} else if (data.canvas.toBlob) {
data.canvas.toBlob(callback, file.type);
} else {
return data;
}
return dfd.promise();
},
loadImageMetaData: function (data, options) {
if (options.disabled) {
return data;
}
var that = this,
dfd = $.Deferred();
loadImage.parseMetaData(data.files[data.index], function (result) {
$.extend(data, result);
dfd.resolveWith(that, [data]);
}, options);
return dfd.promise();
},
saveImageMetaData: function (data, options) {
if (!(data.imageHead && data.canvas &&
data.canvas.toBlob && !options.disabled)) {
return data;
}
var file = data.files[data.index],
blob = new Blob([
data.imageHead,
// Resized images always have a head size of 20 bytes,
// including the JPEG marker and a minimal JFIF header:
this._blobSlice.call(file, 20)
], {type: file.type});
blob.name = file.name;
data.files[data.index] = blob;
return data;
},
// Sets the resized version of the image as a property of the
// file object, must be called after "saveImage":
setImage: function (data, options) {
if (data.preview && !options.disabled) {
data.files[data.index][options.name || 'preview'] = data.preview;
}
return data;
}
}
});
}));

View File

@@ -0,0 +1,164 @@
/*
* jQuery File Upload Processing Plugin 1.2.2
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true */
/*global define, window */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'./jquery.fileupload'
], factory);
} else {
// Browser globals:
factory(
window.jQuery
);
}
}(function ($) {
'use strict';
var originalAdd = $.blueimp.fileupload.prototype.options.add;
// The File Upload Processing plugin extends the fileupload widget
// with file processing functionality:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
options: {
// The list of processing actions:
processQueue: [
/*
{
action: 'log',
type: 'debug'
}
*/
],
add: function (e, data) {
var $this = $(this);
data.process(function () {
return $this.fileupload('process', data);
});
originalAdd.call(this, e, data);
}
},
processActions: {
/*
log: function (data, options) {
console[options.type](
'Processing "' + data.files[data.index].name + '"'
);
}
*/
},
_processFile: function (data) {
var that = this,
dfd = $.Deferred().resolveWith(that, [data]),
chain = dfd.promise();
this._trigger('process', null, data);
$.each(data.processQueue, function (i, settings) {
var func = function (data) {
return that.processActions[settings.action].call(
that,
data,
settings
);
};
chain = chain.pipe(func, settings.always && func);
});
chain
.done(function () {
that._trigger('processdone', null, data);
that._trigger('processalways', null, data);
})
.fail(function () {
that._trigger('processfail', null, data);
that._trigger('processalways', null, data);
});
return chain;
},
// Replaces the settings of each processQueue item that
// are strings starting with an "@", using the remaining
// substring as key for the option map,
// e.g. "@autoUpload" is replaced with options.autoUpload:
_transformProcessQueue: function (options) {
var processQueue = [];
$.each(options.processQueue, function () {
var settings = {},
action = this.action,
prefix = this.prefix === true ? action : this.prefix;
$.each(this, function (key, value) {
if ($.type(value) === 'string' &&
value.charAt(0) === '@') {
settings[key] = options[
value.slice(1) || (prefix ? prefix +
key.charAt(0).toUpperCase() + key.slice(1) : key)
];
} else {
settings[key] = value;
}
});
processQueue.push(settings);
});
options.processQueue = processQueue;
},
// Returns the number of files currently in the processsing queue:
processing: function () {
return this._processing;
},
// Processes the files given as files property of the data parameter,
// returns a Promise object that allows to bind callbacks:
process: function (data) {
var that = this,
options = $.extend({}, this.options, data);
if (options.processQueue && options.processQueue.length) {
this._transformProcessQueue(options);
if (this._processing === 0) {
this._trigger('processstart');
}
$.each(data.files, function (index) {
var opts = index ? $.extend({}, options) : options,
func = function () {
return that._processFile(opts);
};
opts.index = index;
that._processing += 1;
that._processingQueue = that._processingQueue.pipe(func, func)
.always(function () {
that._processing -= 1;
if (that._processing === 0) {
that._trigger('processstop');
}
});
});
}
return this._processingQueue;
},
_create: function () {
this._super();
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}
});
}));

View File

@@ -0,0 +1,117 @@
/*
* jQuery File Upload Validation Plugin 1.1.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'./jquery.fileupload-process'
], factory);
} else {
// Browser globals:
factory(
window.jQuery
);
}
}(function ($) {
'use strict';
// Append to the default processQueue:
$.blueimp.fileupload.prototype.options.processQueue.push(
{
action: 'validate',
// Always trigger this action,
// even if the previous action was rejected:
always: true,
// Options taken from the global options map:
acceptFileTypes: '@',
maxFileSize: '@',
minFileSize: '@',
maxNumberOfFiles: '@',
disabled: '@disableValidation'
}
);
// The File Upload Validation plugin extends the fileupload widget
// with file validation functionality:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
options: {
/*
// The regular expression for allowed file types, matches
// against either file type or file name:
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
// The maximum allowed file size in bytes:
maxFileSize: 10000000, // 10 MB
// The minimum allowed file size in bytes:
minFileSize: undefined, // No minimal file size
// The limit of files to be uploaded:
maxNumberOfFiles: 10,
*/
// Function returning the current number of files,
// has to be overriden for maxNumberOfFiles validation:
getNumberOfFiles: $.noop,
// Error and info messages:
messages: {
maxNumberOfFiles: 'Maximum number of files exceeded',
acceptFileTypes: 'File type not allowed',
maxFileSize: 'File is too large',
minFileSize: 'File is too small'
}
},
processActions: {
validate: function (data, options) {
if (options.disabled) {
return data;
}
var dfd = $.Deferred(),
settings = this.options,
file = data.files[data.index];
if ($.type(options.maxNumberOfFiles) === 'number' &&
(settings.getNumberOfFiles() || 0) + data.files.length >
options.maxNumberOfFiles) {
file.error = settings.i18n('maxNumberOfFiles');
} else if (options.acceptFileTypes &&
!(options.acceptFileTypes.test(file.type) ||
options.acceptFileTypes.test(file.name))) {
file.error = settings.i18n('acceptFileTypes');
} else if (options.maxFileSize && file.size >
options.maxFileSize) {
file.error = settings.i18n('maxFileSize');
} else if ($.type(file.size) === 'number' &&
file.size < options.minFileSize) {
file.error = settings.i18n('minFileSize');
} else {
delete file.error;
}
if (file.error || data.files.error) {
data.files.error = true;
dfd.rejectWith(this, [data]);
} else {
dfd.resolveWith(this, [data]);
}
return dfd.promise();
}
}
});
}));

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright 2010, Sebastian Tschan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
/*
* jQuery Iframe Transport Plugin 1.8.0
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint unparam: true, nomen: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['jquery'], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// Helper variable to create unique names for the transport iframes:
var counter = 0;
// The iframe transport accepts four additional options:
// options.fileInput: a jQuery collection of file input fields
// options.paramName: the parameter name for the file form data,
// overrides the name property of the file input field(s),
// can be a string or an array of strings.
// options.formData: an array of objects with name and value properties,
// equivalent to the return data of .serializeArray(), e.g.:
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
// options.initialIframeSrc: the URL of the initial iframe src,
// by default set to "javascript:false;"
$.ajaxTransport('iframe', function (options) {
if (options.async) {
// javascript:false as initial iframe src
// prevents warning popups on HTTPS in IE6:
var initialIframeSrc = options.initialIframeSrc || 'javascript:false;',
form,
iframe,
addParamChar;
return {
send: function (_, completeCallback) {
form = $('<form style="display:none;"></form>');
form.attr('accept-charset', options.formAcceptCharset);
addParamChar = /\?/.test(options.url) ? '&' : '?';
// XDomainRequest only supports GET and POST:
if (options.type === 'DELETE') {
options.url = options.url + addParamChar + '_method=DELETE';
options.type = 'POST';
} else if (options.type === 'PUT') {
options.url = options.url + addParamChar + '_method=PUT';
options.type = 'POST';
} else if (options.type === 'PATCH') {
options.url = options.url + addParamChar + '_method=PATCH';
options.type = 'POST';
}
// IE versions below IE8 cannot set the name property of
// elements that have already been added to the DOM,
// so we set the name along with the iframe HTML markup:
counter += 1;
iframe = $(
'<iframe src="' + initialIframeSrc +
'" name="iframe-transport-' + counter + '"></iframe>'
).bind('load', function () {
var fileInputClones,
paramNames = $.isArray(options.paramName) ?
options.paramName : [options.paramName];
iframe
.unbind('load')
.bind('load', function () {
var response;
// Wrap in a try/catch block to catch exceptions thrown
// when trying to access cross-domain iframe contents:
try {
response = iframe.contents();
// Google Chrome and Firefox do not throw an
// exception when calling iframe.contents() on
// cross-domain requests, so we unify the response:
if (!response.length || !response[0].firstChild) {
throw new Error();
}
} catch (e) {
response = undefined;
}
// The complete callback returns the
// iframe content document as response object:
completeCallback(
200,
'success',
{'iframe': response}
);
// Fix for IE endless progress bar activity bug
// (happens on form submits to iframe targets):
$('<iframe src="' + initialIframeSrc + '"></iframe>')
.appendTo(form);
window.setTimeout(function () {
// Removing the form in a setTimeout call
// allows Chrome's developer tools to display
// the response result
form.remove();
}, 0);
});
form
.prop('target', iframe.prop('name'))
.prop('action', options.url)
.prop('method', options.type);
if (options.formData) {
$.each(options.formData, function (index, field) {
$('<input type="hidden"/>')
.prop('name', field.name)
.val(field.value)
.appendTo(form);
});
}
if (options.fileInput && options.fileInput.length &&
options.type === 'POST') {
fileInputClones = options.fileInput.clone();
// Insert a clone for each file input field:
options.fileInput.after(function (index) {
return fileInputClones[index];
});
if (options.paramName) {
options.fileInput.each(function (index) {
$(this).prop(
'name',
paramNames[index] || options.paramName
);
});
}
// Appending the file input fields to the hidden form
// removes them from their original location:
form
.append(options.fileInput)
.prop('enctype', 'multipart/form-data')
// enctype must be set as encoding for IE:
.prop('encoding', 'multipart/form-data');
}
form.submit();
// Insert the file input fields at their original location
// by replacing the clones with the originals:
if (fileInputClones && fileInputClones.length) {
options.fileInput.each(function (index, input) {
var clone = $(fileInputClones[index]);
$(input).prop('name', clone.prop('name'));
clone.replaceWith(input);
});
}
});
form.append(iframe).appendTo(document.body);
},
abort: function () {
if (iframe) {
// javascript:false as iframe src aborts the request
// and prevents warning popups on HTTPS in IE6.
// concat is used to avoid the "Script URL" JSLint error:
iframe
.unbind('load')
.prop('src', initialIframeSrc);
}
if (form) {
form.remove();
}
}
};
}
});
// The iframe transport returns the iframe content document as response.
// The following adds converters from iframe to text, json, html, xml
// and script.
// Please note that the Content-Type for JSON responses has to be text/plain
// or text/html, if the browser doesn't include application/json in the
// Accept header, else IE will show a download dialog.
// The Content-Type for XML responses on the other hand has to be always
// application/xml or text/xml, so IE properly parses the XML response.
// See also
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
$.ajaxSetup({
converters: {
'iframe text': function (iframe) {
return iframe && $(iframe[0].body).text();
},
'iframe json': function (iframe) {
return iframe && $.parseJSON($(iframe[0].body).text());
},
'iframe html': function (iframe) {
return iframe && $(iframe[0].body).html();
},
'iframe xml': function (iframe) {
var xmlDoc = iframe && iframe[0];
return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
$.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
$(xmlDoc.body).html());
},
'iframe script': function (iframe) {
return iframe && $.globalEval($(iframe[0].body).text());
}
}
});
}));

View File

@@ -0,0 +1,32 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Modernizr.load([
{
test: window.matchMedia,
nope: [baseAdminDir + "themes/default/js/vendor/matchMedia.js", baseAdminDir + "themes/default/js/vendor/matchMedia.addListener.js"]
},
baseAdminDir + "themes/default/js/vendor/enquire.min.js",
baseAdminDir + "themes/default/js/admin-theme.js",
]);

View File

@@ -0,0 +1,26 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import '../sass/font.scss';
import '../sass/admin-theme.sass';

View File

@@ -0,0 +1,274 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
var Tree = function (element, options)
{
this.$element = $(element);
this.options = $.extend({}, $.fn.tree.defaults, options);
this.init();
};
function getCategoryById(param) {
var elem = null;
$('input[name=id_parent]').each(function (index) {
if ($(this).val() === param + '') {
elem = $(this);
}
});
return elem;
}
function disableTreeItem(item) {
item.find('input[name=id_parent]').attr('disabled', 'disabled');
if (item.hasClass('tree-folder')) {
item.find('span.tree-folder-name').addClass('tree-folder-name-disable');
item.find('ul li').each(function (index) {
disableTreeItem($(this));
});
} else if (item.hasClass('tree-item')) {
item.addClass('tree-item-disable');
}
}
function organizeTree() {
if ($('#id_category').length != 0) {
var id = $('#id_category').val();
var item = getCategoryById(id).parent().parent();
disableTreeItem(item);
}
}
Tree.prototype =
{
constructor: Tree,
init: function ()
{
var that = $(this);
var name = this.$element.parent().find('ul.tree input').first().attr('name');
var idTree = this.$element.parent().find('.cattree.tree').first().attr('id');
this.$element.find("label.tree-toggler, .icon-folder-close, .icon-folder-open").unbind('click');
this.$element.find("label.tree-toggler, .icon-folder-close, .icon-folder-open").click(
function ()
{
if ($(this).parent().parent().children("ul.tree").is(":visible"))
{
$(this).parent().children(".icon-folder-open")
.removeClass("icon-folder-open")
.addClass("icon-folder-close");
that.trigger('collapse');
$(this).parent().parent().children("ul.tree").toggle(300);
}
else
{
$(this).parent().children(".icon-folder-close")
.removeClass("icon-folder-close")
.addClass("icon-folder-open");
var load_tree = (typeof(idTree) != 'undefined'
&& $(this).parent().closest('.tree-folder').find('ul.tree .tree-toggler').first().html() == '');
if (load_tree)
{
var category = $(this).parent().children('ul.tree input').first().val();
var inputType = $(this).parent().children('ul.tree input').first().attr('type');
var useCheckBox = 0;
if (inputType == 'checkbox')
{
useCheckBox = 1;
}
var thatOne = $(this);
$.get(
'ajax-tab.php',
{controller:'AdminProducts',token:currentToken,action:'getCategoryTree',type:idTree,category:category,inputName:name,useCheckBox:useCheckBox},
function(content)
{
thatOne.parent().closest('.tree-folder').find('ul.tree').html(content);
$('#'+idTree).tree('collapse', thatOne.closest('.tree-folder').children("ul.tree"));
that.trigger('expand');
thatOne.parent().parent().children("ul.tree").toggle(300);
$('#'+idTree).tree('init');
}
);
}
else
{
that.trigger('expand');
$(this).parent().parent().children("ul.tree").toggle(300);
}
}
}
);
this.$element.find("li").unbind('click');
this.$element.find("li").click(
function ()
{
$('.tree-selected').removeClass("tree-selected");
$('li input:checked').parent().addClass("tree-selected");
}
);
if (typeof(idTree) != 'undefined')
{
if ($('select#id_category_default').length)
{
this.$element.find(':input[type=checkbox]').unbind('click');
this.$element.find(':input[type=checkbox]').click(function()
{
if ($(this).prop('checked'))
addDefaultCategory($(this));
else
{
$('select#id_category_default option[value=' + $(this).val() + ']').remove();
if ($('select#id_category_default option').length == 0)
{
$('select#id_category_default').closest('.form-group').hide();
$('#no_default_category').show();
}
}
});
}
if (typeof(treeClickFunc) != 'undefined')
{
this.$element.find(":input[type=radio]").unbind('click');
this.$element.find(":input[type=radio]").click(treeClickFunc);
}
}
return $(this);
},
collapse : function(elem, $speed)
{
elem.find("label.tree-toggler").each(
function()
{
$(this).parent().children(".icon-folder-open")
.removeClass("icon-folder-open")
.addClass("icon-folder-close");
$(this).parent().parent().children("ul.tree").hide($speed);
}
);
return $(this);
},
collapseAll : function($speed)
{
this.$element.find("label.tree-toggler").each(
function()
{
$(this).parent().children(".icon-folder-open")
.removeClass("icon-folder-open")
.addClass("icon-folder-close");
$(this).parent().parent().children("ul.tree").hide($speed);
}
);
return $(this);
},
expandAll : function($speed)
{
var idTree = this.$element.parent().find('.cattree.tree').first().attr('id');
if (typeof(idTree) != 'undefined' && !$('#'+idTree).hasClass('full_loaded'))
{
var selected = [];
that = this;
$('#'+idTree).find('.tree-selected input').each(
function()
{
selected.push($(this).val());
}
);
var name = $('#'+idTree).find('ul.tree input').first().attr('name');
var inputType = $('#'+idTree).find('ul.tree input').first().attr('type');
var useCheckBox = 0;
if (inputType == 'checkbox')
{
useCheckBox = 1;
}
$.get(
'ajax-tab.php',
{controller:'AdminProducts',token:currentToken,action:'getCategoryTree',type:idTree,fullTree:1,selected:selected, inputName:name,useCheckBox:useCheckBox},
function(content)
{
$('#' + idTree).html(content);
organizeTree();
$('#' + idTree).tree('init');
that.$element.find("label.tree-toggler").each(
function()
{
$(this).parent().children(".icon-folder-close")
.removeClass("icon-folder-close")
.addClass("icon-folder-open");
$(this).parent().parent().children("ul.tree").show($speed);
$('#'+idTree).addClass('full_loaded');
}
);
}
);
}
else
{
this.$element.find("label.tree-toggler").each(
function()
{
$(this).parent().children(".icon-folder-close")
.removeClass("icon-folder-close")
.addClass("icon-folder-open");
$(this).parent().parent().children("ul.tree").show($speed);
}
);
}
return $(this);
}
};
$.fn.tree = function (option, value)
{
var methodReturn;
var $set = this.each(
function ()
{
var $this = $(this);
var data = $this.data('tree');
var options = typeof option === 'object' && option;
if (!data){
$this.data('tree', (data = new Tree(this, options)));
}
if (typeof option === 'string') {
methodReturn = data[option](value);
}
}
);
return (methodReturn === undefined) ? $set : methodReturn;
};
$.fn.tree.Constructor = Tree;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2011-2015 Twitter, Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,135 @@
/* ========================================================================
* Bootstrap: affix.js v3.1.1
* http://getbootstrap.com/javascript/#affix
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// AFFIX CLASS DEFINITION
// ======================
var Affix = function (element, options) {
this.options = $.extend({}, Affix.DEFAULTS, options)
this.$window = $(window)
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
this.$element = $(element)
this.affixed =
this.unpin =
this.pinnedOffset = null
this.checkPosition()
}
Affix.RESET = 'affix affix-top affix-bottom'
Affix.DEFAULTS = {
offset: 0
}
Affix.prototype.getPinnedOffset = function () {
if (this.pinnedOffset) return this.pinnedOffset
this.$element.removeClass(Affix.RESET).addClass('affix')
var scrollTop = this.$window.scrollTop()
var position = this.$element.offset()
return (this.pinnedOffset = position.top - scrollTop)
}
Affix.prototype.checkPositionWithEventLoop = function () {
setTimeout($.proxy(this.checkPosition, this), 1)
}
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var scrollHeight = $(document).height()
var scrollTop = this.$window.scrollTop()
var position = this.$element.offset()
var offset = this.options.offset
var offsetTop = offset.top
var offsetBottom = offset.bottom
if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return
if (this.unpin != null) this.$element.css('top', '')
var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix')
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
this.affixed = affix
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
this.$element
.removeClass(Affix.RESET)
.addClass(affixType)
.trigger($.Event(affixType.replace('affix', 'affixed')))
if (affix == 'bottom') {
this.$element.offset({ top: position.top })
}
}
// AFFIX PLUGIN DEFINITION
// =======================
var old = $.fn.affix
$.fn.affix = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.affix')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.affix.Constructor = Affix
// AFFIX NO CONFLICT
// =================
$.fn.affix.noConflict = function () {
$.fn.affix = old
return this
}
// AFFIX DATA-API
// ==============
$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
var data = $spy.data()
data.offset = data.offset || {}
if (data.offsetBottom) data.offset.bottom = data.offsetBottom
if (data.offsetTop) data.offset.top = data.offsetTop
$spy.affix(data)
})
})
}(jQuery);

View File

@@ -0,0 +1,88 @@
/* ========================================================================
* Bootstrap: alert.js v3.1.1
* http://getbootstrap.com/javascript/#alerts
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// ALERT CLASS DEFINITION
// ======================
var dismiss = '[data-dismiss="alert"]'
var Alert = function (el) {
$(el).on('click', dismiss, this.close)
}
Alert.prototype.close = function (e) {
var $this = $(this)
var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
var $parent = $(selector)
if (e) e.preventDefault()
if (!$parent.length) {
$parent = $this.hasClass('alert') ? $this : $this.parent()
}
$parent.trigger(e = $.Event('close.bs.alert'))
if (e.isDefaultPrevented()) return
$parent.removeClass('in')
function removeElement() {
$parent.trigger('closed.bs.alert').remove()
}
$.support.transition && $parent.hasClass('fade') ?
$parent
.one($.support.transition.end, removeElement)
.emulateTransitionEnd(150) :
removeElement()
}
// ALERT PLUGIN DEFINITION
// =======================
var old = $.fn.alert
$.fn.alert = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.alert')
if (!data) $this.data('bs.alert', (data = new Alert(this)))
if (typeof option == 'string') data[option].call($this)
})
}
$.fn.alert.Constructor = Alert
// ALERT NO CONFLICT
// =================
$.fn.alert.noConflict = function () {
$.fn.alert = old
return this
}
// ALERT DATA-API
// ==============
$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
}(jQuery);

View File

@@ -0,0 +1,107 @@
/* ========================================================================
* Bootstrap: button.js v3.1.1
* http://getbootstrap.com/javascript/#buttons
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// BUTTON PUBLIC CLASS DEFINITION
// ==============================
var Button = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, Button.DEFAULTS, options)
this.isLoading = false
}
Button.DEFAULTS = {
loadingText: 'loading...'
}
Button.prototype.setState = function (state) {
var d = 'disabled'
var $el = this.$element
var val = $el.is('input') ? 'val' : 'html'
var data = $el.data()
state = state + 'Text'
if (!data.resetText) $el.data('resetText', $el[val]())
$el[val](data[state] || this.options[state])
// push to event loop to allow forms to submit
setTimeout($.proxy(function () {
if (state == 'loadingText') {
this.isLoading = true
$el.addClass(d).attr(d, d)
} else if (this.isLoading) {
this.isLoading = false
$el.removeClass(d).removeAttr(d)
}
}, this), 0)
}
Button.prototype.toggle = function () {
var changed = true
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) {
var $input = this.$element.find('input')
if ($input.prop('type') == 'radio') {
if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
else $parent.find('.active').removeClass('active')
}
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
}
if (changed) this.$element.toggleClass('active')
}
// BUTTON PLUGIN DEFINITION
// ========================
var old = $.fn.button
$.fn.button = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.button')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.button', (data = new Button(this, options)))
if (option == 'toggle') data.toggle()
else if (option) data.setState(option)
})
}
$.fn.button.Constructor = Button
// BUTTON NO CONFLICT
// ==================
$.fn.button.noConflict = function () {
$.fn.button = old
return this
}
// BUTTON DATA-API
// ===============
$(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
e.preventDefault()
})
}(jQuery);

View File

@@ -0,0 +1,205 @@
/* ========================================================================
* Bootstrap: carousel.js v3.1.1
* http://getbootstrap.com/javascript/#carousel
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// CAROUSEL CLASS DEFINITION
// =========================
var Carousel = function (element, options) {
this.$element = $(element)
this.$indicators = this.$element.find('.carousel-indicators')
this.options = options
this.paused =
this.sliding =
this.interval =
this.$active =
this.$items = null
this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this))
}
Carousel.DEFAULTS = {
interval: 5000,
pause: 'hover',
wrap: true
}
Carousel.prototype.cycle = function (e) {
e || (this.paused = false)
this.interval && clearInterval(this.interval)
this.options.interval
&& !this.paused
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
Carousel.prototype.getActiveIndex = function () {
this.$active = this.$element.find('.item.active')
this.$items = this.$active.parent().children('.item')
return this.$items.index(this.$active)
}
Carousel.prototype.to = function (pos) {
var that = this
var activeIndex = this.getActiveIndex()
if (pos > (this.$items.length - 1) || pos < 0) return
if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid". not a typo. past tense of "to slide".
if (activeIndex == pos) return this.pause().cycle()
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
}
Carousel.prototype.pause = function (e) {
e || (this.paused = true)
if (this.$element.find('.next, .prev').length && $.support.transition) {
this.$element.trigger($.support.transition.end)
this.cycle(true)
}
this.interval = clearInterval(this.interval)
return this
}
Carousel.prototype.next = function () {
if (this.sliding) return
return this.slide('next')
}
Carousel.prototype.prev = function () {
if (this.sliding) return
return this.slide('prev')
}
Carousel.prototype.slide = function (type, next) {
var $active = this.$element.find('.item.active')
var $next = next || $active[type]()
var isCycling = this.interval
var direction = type == 'next' ? 'left' : 'right'
var fallback = type == 'next' ? 'first' : 'last'
var that = this
if (!$next.length) {
if (!this.options.wrap) return
$next = this.$element.find('.item')[fallback]()
}
if ($next.hasClass('active')) return this.sliding = false
var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
this.sliding = true
isCycling && this.pause()
if (this.$indicators.length) {
this.$indicators.find('.active').removeClass('active')
this.$element.one('slid.bs.carousel', function () { // yes, "slid". not a typo. past tense of "to slide".
var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
$nextIndicator && $nextIndicator.addClass('active')
})
}
if ($.support.transition && this.$element.hasClass('slide')) {
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
$active
.one($.support.transition.end, function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) // yes, "slid". not a typo. past tense of "to slide".
})
.emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
} else {
$active.removeClass('active')
$next.addClass('active')
this.sliding = false
this.$element.trigger('slid.bs.carousel') // yes, "slid". not a typo. past tense of "to slide".
}
isCycling && this.cycle()
return this
}
// CAROUSEL PLUGIN DEFINITION
// ==========================
var old = $.fn.carousel
$.fn.carousel = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.carousel')
var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option)
else if (action) data[action]()
else if (options.interval) data.pause().cycle()
})
}
$.fn.carousel.Constructor = Carousel
// CAROUSEL NO CONFLICT
// ====================
$.fn.carousel.noConflict = function () {
$.fn.carousel = old
return this
}
// CAROUSEL DATA-API
// =================
$(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
var $this = $(this), href
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
var options = $.extend({}, $target.data(), $this.data())
var slideIndex = $this.attr('data-slide-to')
if (slideIndex) options.interval = false
$target.carousel(options)
if (slideIndex = $this.attr('data-slide-to')) {
$target.data('bs.carousel').to(slideIndex)
}
e.preventDefault()
})
$(window).on('load', function () {
$('[data-ride="carousel"]').each(function () {
var $carousel = $(this)
$carousel.carousel($carousel.data())
})
})
}(jQuery);

View File

@@ -0,0 +1,175 @@
/* ========================================================================
* Bootstrap: collapse.js v3.1.1
* http://getbootstrap.com/javascript/#collapse
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// COLLAPSE PUBLIC CLASS DEFINITION
// ================================
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, Collapse.DEFAULTS, options)
this.transitioning = null
if (this.options.parent) this.$parent = $(this.options.parent)
if (this.options.toggle) this.toggle()
}
Collapse.DEFAULTS = {
toggle: true
}
Collapse.prototype.dimension = function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
Collapse.prototype.show = function () {
if (this.transitioning || this.$element.hasClass('in')) return
var startEvent = $.Event('show.bs.collapse')
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
var actives = this.$parent && this.$parent.find('> .panel > .in')
if (actives && actives.length) {
var hasData = actives.data('bs.collapse')
if (hasData && hasData.transitioning) return
actives.collapse('hide')
hasData || actives.data('bs.collapse', null)
}
var dimension = this.dimension()
this.$element
.removeClass('collapse')
.addClass('collapsing')[dimension](0)
this.transitioning = 1
var complete = function (e) {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
this.$element
.removeClass('collapsing')
.addClass('collapse in')[dimension]('')
this.transitioning = 0
this.$element.trigger('shown.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
}
Collapse.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('in')) return
var startEvent = $.Event('hide.bs.collapse')
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
this.$element[dimension](this.$element[dimension]())[0].offsetHeight
this.$element
.addClass('collapsing')
.removeClass('collapse')
.removeClass('in')
this.transitioning = 1
var complete = function (e) {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
this.transitioning = 0
this.$element
.trigger('hidden.bs.collapse')
.removeClass('collapsing')
.addClass('collapse')
}
if (!$.support.transition) return complete.call(this)
this.$element
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
}
Collapse.prototype.toggle = function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
// COLLAPSE PLUGIN DEFINITION
// ==========================
var old = $.fn.collapse
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.collapse')
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data && options.toggle && option == 'show') option = !option
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.collapse.Constructor = Collapse
// COLLAPSE NO CONFLICT
// ====================
$.fn.collapse.noConflict = function () {
$.fn.collapse = old
return this
}
// COLLAPSE DATA-API
// =================
$(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
var $this = $(this), href
var target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
var $target = $(target)
var data = $target.data('bs.collapse')
var option = data ? 'toggle' : $this.data()
var parent = $this.attr('data-parent')
var $parent = parent && $(parent)
if (!data || !data.transitioning) {
if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
}
$target.collapse(option)
})
}(jQuery);

View File

@@ -0,0 +1,148 @@
/* ========================================================================
* Bootstrap: dropdown.js v3.1.1
* http://getbootstrap.com/javascript/#dropdowns
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// DROPDOWN CLASS DEFINITION
// =========================
var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
}
Dropdown.prototype.toggle = function (e) {
var $this = $(this)
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
}
var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.trigger('focus')
$parent
.toggleClass('open')
.trigger('shown.bs.dropdown', relatedTarget)
}
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27)/.test(e.keyCode)) return
var $this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.trigger('click')
}
var desc = ' li:not(.divider):visible a'
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return
var index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items.eq(index).trigger('focus')
}
function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove()
$(toggle).each(function () {
var $parent = getParent($(this))
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
})
}
function getParent($this) {
var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
var $parent = selector && $(selector)
return $parent && $parent.length ? $parent : $this.parent()
}
// DROPDOWN PLUGIN DEFINITION
// ==========================
var old = $.fn.dropdown
$.fn.dropdown = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.dropdown')
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this)
})
}
$.fn.dropdown.Constructor = Dropdown
// DROPDOWN NO CONFLICT
// ====================
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
// APPLY TO STANDARD DROPDOWN ELEMENTS
// ===================================
$(document)
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
}(jQuery);

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop and Contributors
*
* 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-2019 PrestaShop SA and Contributors
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,275 @@
/* ========================================================================
* Bootstrap: modal.js v3.1.1
* http://getbootstrap.com/javascript/#modals
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// MODAL CLASS DEFINITION
// ======================
var Modal = function (element, options) {
this.options = options
this.$body = $(document.body)
this.$element = $(element)
this.$backdrop =
this.isShown = null
this.scrollbarWidth = 0
if (this.options.remote) {
this.$element
.find('.modal-content')
.load(this.options.remote, $.proxy(function () {
this.$element.trigger('loaded.bs.modal')
}, this))
}
}
Modal.DEFAULTS = {
backdrop: true,
keyboard: true,
show: true
}
Modal.prototype.toggle = function (_relatedTarget) {
return this.isShown ? this.hide() : this.show(_relatedTarget)
}
Modal.prototype.show = function (_relatedTarget) {
var that = this
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
this.$element.trigger(e)
if (this.isShown || e.isDefaultPrevented()) return
this.isShown = true
this.checkScrollbar()
this.$body.addClass('modal-open')
this.setScrollbar()
this.escape()
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(that.$body) // don't move modals dom position
}
that.$element
.show()
.scrollTop(0)
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false)
that.enforceFocus()
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
transition ?
that.$element.find('.modal-dialog') // wait for modal to slide in
.one($.support.transition.end, function () {
that.$element.trigger('focus').trigger(e)
})
.emulateTransitionEnd(300) :
that.$element.trigger('focus').trigger(e)
})
}
Modal.prototype.hide = function (e) {
if (e) e.preventDefault()
e = $.Event('hide.bs.modal')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
this.$body.removeClass('modal-open')
this.resetScrollbar()
this.escape()
$(document).off('focusin.bs.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal')
$.support.transition && this.$element.hasClass('fade') ?
this.$element
.one($.support.transition.end, $.proxy(this.hideModal, this))
.emulateTransitionEnd(300) :
this.hideModal()
}
Modal.prototype.enforceFocus = function () {
$(document)
.off('focusin.bs.modal') // guard against infinite focus loop
.on('focusin.bs.modal', $.proxy(function (e) {
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.trigger('focus')
}
}, this))
}
Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
e.which == 27 && this.hide()
}, this))
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.bs.modal')
}
}
Modal.prototype.hideModal = function () {
var that = this
this.$element.hide()
this.backdrop(function () {
that.$element.trigger('hidden.bs.modal')
})
}
Modal.prototype.removeBackdrop = function () {
this.$backdrop && this.$backdrop.remove()
this.$backdrop = null
}
Modal.prototype.backdrop = function (callback) {
var that = this
var animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(this.$body)
this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
if (e.target !== e.currentTarget) return
this.options.backdrop == 'static'
? this.$element[0].focus.call(this.$element[0])
: this.hide.call(this)
}, this))
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
if (!callback) return
doAnimate ?
this.$backdrop
.one($.support.transition.end, callback)
.emulateTransitionEnd(150) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
var callbackRemove = function() {
that.removeBackdrop()
callback && callback()
}
$.support.transition && this.$element.hasClass('fade') ?
this.$backdrop
.one($.support.transition.end, callbackRemove)
.emulateTransitionEnd(150) :
callbackRemove()
} else if (callback) {
callback()
}
}
Modal.prototype.checkScrollbar = function () {
if (document.body.clientWidth >= window.innerWidth) return
this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
}
Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt(this.$body.css('padding-right') || 0)
if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
}
Modal.prototype.resetScrollbar = function () {
this.$body.css('padding-right', '')
}
Modal.prototype.measureScrollbar = function () { // thx walsh
var scrollDiv = document.createElement('div')
scrollDiv.className = 'modal-scrollbar-measure'
this.$body.append(scrollDiv)
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
this.$body[0].removeChild(scrollDiv)
return scrollbarWidth
}
// MODAL PLUGIN DEFINITION
// =======================
var old = $.fn.modal
$.fn.modal = function (option, _relatedTarget) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.modal')
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option](_relatedTarget)
else if (options.show) data.show(_relatedTarget)
})
}
$.fn.modal.Constructor = Modal
// MODAL NO CONFLICT
// =================
$.fn.modal.noConflict = function () {
$.fn.modal = old
return this
}
// MODAL DATA-API
// ==============
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this)
var href = $this.attr('href')
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
if ($this.is('a')) e.preventDefault()
$target
.modal(option, this)
.one('hide', function () {
$this.is(':visible') && $this.trigger('focus')
})
})
}(jQuery);

View File

@@ -0,0 +1,110 @@
/* ========================================================================
* Bootstrap: popover.js v3.1.1
* http://getbootstrap.com/javascript/#popovers
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// POPOVER PUBLIC CLASS DEFINITION
// ===============================
var Popover = function (element, options) {
this.init('popover', element, options)
}
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right',
trigger: 'click',
content: '',
template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
})
// NOTE: POPOVER EXTENDS tooltip.js
// ================================
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
Popover.prototype.constructor = Popover
Popover.prototype.getDefaults = function () {
return Popover.DEFAULTS
}
Popover.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
var content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
](content)
$tip.removeClass('fade top bottom left right in')
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
// this manually by checking the contents.
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
}
Popover.prototype.hasContent = function () {
return this.getTitle() || this.getContent()
}
Popover.prototype.getContent = function () {
var $e = this.$element
var o = this.options
return $e.attr('data-content')
|| (typeof o.content == 'function' ?
o.content.call($e[0]) :
o.content)
}
Popover.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.arrow')
}
Popover.prototype.tip = function () {
if (!this.$tip) this.$tip = $(this.options.template)
return this.$tip
}
// POPOVER PLUGIN DEFINITION
// =========================
var old = $.fn.popover
$.fn.popover = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.popover')
var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.popover.Constructor = Popover
// POPOVER NO CONFLICT
// ===================
$.fn.popover.noConflict = function () {
$.fn.popover = old
return this
}
}(jQuery);

View File

@@ -0,0 +1,154 @@
/* ========================================================================
* Bootstrap: scrollspy.js v3.1.1
* http://getbootstrap.com/javascript/#scrollspy
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// SCROLLSPY CLASS DEFINITION
// ==========================
function ScrollSpy(element, options) {
var href
var process = $.proxy(this.process, this)
this.$element = $(element).is('body') ? $(window) : $(element)
this.$body = $('body')
this.$scrollElement = this.$element.on('scroll.bs.scrollspy', process)
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a'
this.offsets = $([])
this.targets = $([])
this.activeTarget = null
this.refresh()
this.process()
}
ScrollSpy.DEFAULTS = {
offset: 10
}
ScrollSpy.prototype.refresh = function () {
var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
this.offsets = $([])
this.targets = $([])
var self = this
this.$body
.find(this.selector)
.map(function () {
var $el = $(this)
var href = $el.data('target') || $el.attr('href')
var $href = /^#./.test(href) && $(href)
return ($href
&& $href.length
&& $href.is(':visible')
&& [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
})
.sort(function (a, b) { return a[0] - b[0] })
.each(function () {
self.offsets.push(this[0])
self.targets.push(this[1])
})
}
ScrollSpy.prototype.process = function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
var scrollHeight = this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
var maxScroll = scrollHeight - this.$scrollElement.height()
var offsets = this.offsets
var targets = this.targets
var activeTarget = this.activeTarget
var i
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0]) && this.activate(i)
}
if (activeTarget && scrollTop <= offsets[0]) {
return activeTarget != (i = targets[0]) && this.activate(i)
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate( targets[i] )
}
}
ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target
$(this.selector)
.parentsUntil(this.options.target, '.active')
.removeClass('active')
var selector = this.selector +
'[data-target="' + target + '"],' +
this.selector + '[href="' + target + '"]'
var active = $(selector)
.parents('li')
.addClass('active')
if (active.parent('.dropdown-menu').length) {
active = active
.closest('li.dropdown')
.addClass('active')
}
active.trigger('activate.bs.scrollspy')
}
// SCROLLSPY PLUGIN DEFINITION
// ===========================
var old = $.fn.scrollspy
$.fn.scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.scrollspy')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.scrollspy.Constructor = ScrollSpy
// SCROLLSPY NO CONFLICT
// =====================
$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
return this
}
// SCROLLSPY DATA-API
// ==================
$(window).on('load.bs.scrollspy.data-api', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
$spy.scrollspy($spy.data())
})
})
}(jQuery);

View File

@@ -0,0 +1,125 @@
/* ========================================================================
* Bootstrap: tab.js v3.1.1
* http://getbootstrap.com/javascript/#tabs
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// TAB CLASS DEFINITION
// ====================
var Tab = function (element) {
this.element = $(element)
}
Tab.prototype.show = function () {
var $this = this.element
var $ul = $this.closest('ul:not(.dropdown-menu)')
var selector = $this.data('target')
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
if ($this.parent('li').hasClass('active')) return
var previous = $ul.find('.active:last a')[0]
var e = $.Event('show.bs.tab', {
relatedTarget: previous
})
$this.trigger(e)
if (e.isDefaultPrevented()) return
var $target = $(selector)
this.activate($this.parent('li'), $ul)
this.activate($target, $target.parent(), function () {
$this.trigger({
type: 'shown.bs.tab',
relatedTarget: previous
})
})
}
Tab.prototype.activate = function (element, container, callback) {
var $active = container.find('> .active')
var transition = callback
&& $.support.transition
&& $active.hasClass('fade')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
} else {
element.removeClass('fade')
}
if (element.parent('.dropdown-menu')) {
element.closest('li.dropdown').addClass('active')
}
callback && callback()
}
transition ?
$active
.one($.support.transition.end, next)
.emulateTransitionEnd(150) :
next()
$active.removeClass('in')
}
// TAB PLUGIN DEFINITION
// =====================
var old = $.fn.tab
$.fn.tab = function ( option ) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tab')
if (!data) $this.data('bs.tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]()
})
}
$.fn.tab.Constructor = Tab
// TAB NO CONFLICT
// ===============
$.fn.tab.noConflict = function () {
$.fn.tab = old
return this
}
// TAB DATA-API
// ============
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
$(this).tab('show')
})
}(jQuery);

View File

@@ -0,0 +1,422 @@
/* ========================================================================
* Bootstrap: tooltip.js v3.1.1
* http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
var Tooltip = function (element, options) {
this.type =
this.options =
this.enabled =
this.timeout =
this.hoverState =
this.$element = null
this.init('tooltip', element, options)
}
Tooltip.DEFAULTS = {
animation: true,
placement: 'top',
selector: false,
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
container: false,
viewport: {
selector: 'body',
padding: 0
}
}
Tooltip.prototype.init = function (type, element, options) {
this.enabled = true
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
var triggers = this.options.trigger.split(' ')
for (var i = triggers.length; i--;) {
var trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
Tooltip.prototype.getDefaults = function () {
return Tooltip.DEFAULTS
}
Tooltip.prototype.getOptions = function (options) {
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay,
hide: options.delay
}
}
return options
}
Tooltip.prototype.getDelegateOptions = function () {
var options = {}
var defaults = this.getDefaults()
this._options && $.each(this._options, function (key, value) {
if (defaults[key] != value) options[key] = value
})
return options
}
Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
self.hoverState = 'in'
if (!self.options.delay || !self.options.delay.show) return self.show()
self.timeout = setTimeout(function () {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
self.hoverState = 'out'
if (!self.options.delay || !self.options.delay.hide) return self.hide()
self.timeout = setTimeout(function () {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
}
Tooltip.prototype.show = function () {
var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
var that = this;
var $tip = this.tip()
this.setContent()
if (this.options.animation) $tip.addClass('fade')
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
var autoToken = /\s?auto?\s?/i
var autoPlace = autoToken.test(placement)
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
$tip
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
var pos = this.getPosition()
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (autoPlace) {
var orgPlacement = placement
var $parent = this.$element.parent()
var parentDim = this.getPosition($parent)
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
placement
$tip
.removeClass(orgPlacement)
.addClass(placement)
}
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement)
this.hoverState = null
var complete = function() {
that.$element.trigger('shown.bs.' + that.type)
}
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one($.support.transition.end, complete)
.emulateTransitionEnd(150) :
complete()
}
}
Tooltip.prototype.applyPlacement = function (offset, placement) {
var $tip = this.tip()
var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight
// manually read margins because getBoundingClientRect includes difference
var marginTop = parseInt($tip.css('margin-top'), 10)
var marginLeft = parseInt($tip.css('margin-left'), 10)
// we must check for NaN for ie 8/9
if (isNaN(marginTop)) marginTop = 0
if (isNaN(marginLeft)) marginLeft = 0
offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft
// $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({
using: function (props) {
$tip.css({
top: Math.round(props.top),
left: Math.round(props.left)
})
}
}, offset), 0)
$tip.addClass('in')
// check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
offset.top = offset.top + height - actualHeight
}
var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
if (delta.left) offset.left += delta.left
else offset.top += delta.top
var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
var arrowPosition = delta.left ? 'left' : 'top'
var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
$tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
}
Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
}
Tooltip.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
Tooltip.prototype.hide = function () {
var that = this
var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type)
function complete() {
if (that.hoverState != 'in') $tip.detach()
that.$element.trigger('hidden.bs.' + that.type)
}
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$tip.removeClass('in')
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one($.support.transition.end, complete)
.emulateTransitionEnd(150) :
complete()
this.hoverState = null
return this
}
Tooltip.prototype.fixTitle = function () {
var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
}
}
Tooltip.prototype.hasContent = function () {
return this.getTitle()
}
Tooltip.prototype.getPosition = function ($element) {
$element = $element || this.$element
var el = $element[0]
var isBody = el.tagName == 'BODY'
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
width: isBody ? $(window).width() : $element.outerWidth(),
height: isBody ? $(window).height() : $element.outerHeight()
}, isBody ? {top: 0, left: 0} : $element.offset())
}
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
}
Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
var delta = { top: 0, left: 0 }
if (!this.$viewport) return delta
var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
var viewportDimensions = this.getPosition(this.$viewport)
if (/right|left/.test(placement)) {
var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
if (topEdgeOffset < viewportDimensions.top) { // top overflow
delta.top = viewportDimensions.top - topEdgeOffset
} else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
}
} else {
var leftEdgeOffset = pos.left - viewportPadding
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
delta.left = viewportDimensions.left - leftEdgeOffset
} else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
}
}
return delta
}
Tooltip.prototype.getTitle = function () {
var title
var $e = this.$element
var o = this.options
title = $e.attr('data-original-title')
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template)
}
Tooltip.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
}
Tooltip.prototype.validate = function () {
if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
this.options = null
}
}
Tooltip.prototype.enable = function () {
this.enabled = true
}
Tooltip.prototype.disable = function () {
this.enabled = false
}
Tooltip.prototype.toggleEnabled = function () {
this.enabled = !this.enabled
}
Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
}
Tooltip.prototype.destroy = function () {
clearTimeout(this.timeout)
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
}
// TOOLTIP PLUGIN DEFINITION
// =========================
var old = $.fn.tooltip
$.fn.tooltip = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.tooltip.Constructor = Tooltip
// TOOLTIP NO CONFLICT
// ===================
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old
return this
}
}(jQuery);

View File

@@ -0,0 +1,48 @@
/* ========================================================================
* Bootstrap: transition.js v3.1.1
* http://getbootstrap.com/javascript/#transitions
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
// ============================================================
function transitionEnd() {
var el = document.createElement('bootstrap')
var transEndEventNames = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
}
for (var name in transEndEventNames) {
if (el.style[name] !== undefined) {
return { end: transEndEventNames[name] }
}
}
return false // explicit for ie8 ( ._.)
}
// http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) {
var called = false, $el = this
$(this).one($.support.transition.end, function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration)
return this
}
$(function () {
$.support.transition = transitionEnd()
})
}(jQuery);

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,5 @@
/*!
* enquire.js v2.1.0 - Awesome Media Queries in JavaScript
* Copyright (c) 2013 Nick Williams - http://wicky.nillia.ms/enquire.js
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/(function(e,t,n){var r=t.matchMedia;typeof module!="undefined"&&module.exports?module.exports=n(r):typeof define=="function"&&define.amd?define(function(){return t[e]=n(r)}):t[e]=n(r)})("enquire",this,function(e){"use strict";function t(e,t){var n=0,r=e.length,i;for(n;n<r;n++){i=t(e[n],n);if(i===!1)break}}function n(e){return Object.prototype.toString.apply(e)==="[object Array]"}function r(e){return typeof e=="function"}function i(e){this.options=e;!e.deferSetup&&this.setup()}function s(t,n){this.query=t;this.isUnconditional=n;this.handlers=[];this.mql=e(t);var r=this;this.listener=function(e){r.mql=e;r.assess()};this.mql.addListener(this.listener)}function o(){if(!e)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={};this.browserIsIncapable=!e("only all").matches}i.prototype={setup:function(){this.options.setup&&this.options.setup();this.initialised=!0},on:function(){!this.initialised&&this.setup();this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(e){return this.options===e||this.options.match===e}};s.prototype={addHandler:function(e){var t=new i(e);this.handlers.push(t);this.matches()&&t.on()},removeHandler:function(e){var n=this.handlers;t(n,function(t,r){if(t.equals(e)){t.destroy();return!n.splice(r,1)}})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){t(this.handlers,function(e){e.destroy()});this.mql.removeListener(this.listener);this.handlers.length=0},assess:function(){var e=this.matches()?"on":"off";t(this.handlers,function(t){t[e]()})}};o.prototype={register:function(e,i,o){var u=this.queries,a=o&&this.browserIsIncapable;u[e]||(u[e]=new s(e,a));r(i)&&(i={match:i});n(i)||(i=[i]);t(i,function(t){u[e].addHandler(t)});return this},unregister:function(e,t){var n=this.queries[e];if(n)if(t)n.removeHandler(t);else{n.clear();delete this.queries[e]}return this}};return new o});

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop and Contributors
*
* 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-2019 PrestaShop SA and Contributors
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,216 @@
/*
* jQuery Passy
* Generating and analazing passwords, realtime.
*
* Tim Severien
* http://timseverien.nl
*
* Copyright (c) 2013 Tim Severien
* Released under the GPLv2 license.
*
*/
(function($) {
var passy = {
character: { DIGIT: 1, LOWERCASE: 2, UPPERCASE: 4, PUNCTUATION: 8 },
strength: { LOW: 0, MEDIUM: 1, HIGH: 2, EXTREME: 3 },
dictionary: [],
patterns: [
'0123456789',
'abcdefghijklmnopqrstuvwxyz',
'qwertyuiopasdfghjklzxcvbnm',
'azertyuiopqsdfghjklmwxcvbn',
'!#$*+-.:?@^'
],
threshold: {
medium: 16,
high: 22,
extreme: 36
}
};
passy.requirements = {
characters: passy.character.DIGIT | passy.character.LOWERCASE | passy.character.UPPERCASE,
length: {
min: 6,
max: Infinity
}
};
if(Object.seal) {
Object.seal(passy.character);
Object.seal(passy.strength);
}
if(Object.freeze) {
Object.freeze(passy.character);
Object.freeze(passy.strength);
}
passy.analize = function(password) {
var score = Math.floor(password.length * 2);
var i = password.length;
score += $.passy.analizePatterns(password);
score += $.passy.analizeDictionary(password);
while(i--) score += $.passy.analizeCharacter(password.charAt(i));
return $.passy.analizeScore(score);
};
passy.analizeCharacter = function(character) {
var code = character.charCodeAt(0);
if(code >= 97 && code <= 122) return 1; // lower case
if(code >= 48 && code <= 57) return 2; // numeric
if(code >= 65 && code <= 90) return 3; // capital
if(code <= 126) return 4; // punctuation
return 5; // foreign characters etc
};
passy.analizePattern = function(password, pattern) {
var lastmatch = -1;
var score = -2;
for(var i = 0; i < password.length; i++) {
var match = pattern.indexOf(password.charAt(i));
if(lastmatch === match - 1) {
lastmatch = match;
score++;
}
}
return Math.max(0, score);
};
passy.analizePatterns = function(password) {
var chars = password.toLowerCase();
var score = 0;
for(var i in $.passy.patterns) {
var pattern = $.passy.patterns[i].toLowerCase();
score += $.passy.analizePattern(chars, pattern);
}
// patterns are bad man!
return score * -5;
};
passy.analizeDictionary = function(password) {
var chars = password.toLowerCase();
var score = 0;
for(var i in $.passy.dictionary) {
var word = $.passy.dictionary[i].toLowerCase();
if(password.indexOf(word) >= 0) score++;
}
// using words are bad too!
return score * -5;
};
passy.analizeScore = function(score) {
if(score >= $.passy.threshold.extreme) return $.passy.strength.EXTREME;
if(score >= $.passy.threshold.high) return $.passy.strength.HIGH;
if(score >= $.passy.threshold.medium) return $.passy.strength.MEDIUM;
return $.passy.strength.LOW;
};
passy.generate = function(len) {
var chars = [
'0123456789',
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'!#$&()*+<=>@[]^'
];
var password = [];
var type, index;
len = Math.max(len, $.passy.requirements.length.min);
len = Math.min(len, $.passy.requirements.length.max);
while(len--) {
type = len % chars.length;
index = Math.floor(Math.random() * chars[type].length);
password.push(chars[type].charAt(index));
}
password.sort(function() {
return Math.random() * 2 - 1;
});
return password.join('');
};
passy.contains = function(str, character) {
if(character === $.passy.character.DIGIT) {
return /\d/.test(str);
} else if(character === $.passy.character.LOWERCASE) {
return /[a-z]/.test(str);
} else if(character === $.passy.character.UPPERCASE) {
return /[A-Z]/.test(str);
} else if(character === $.passy.character.PUNCTUATION) {
return /[!"#$%&'()*+,\-./:;<=>?@[\\]\^_`{\|}~]/.test(str);
}
};
passy.valid = function(str) {
var valid = true;
if(!$.passy.requirements) return true;
if(str.length < $.passy.requirements.length.min) return false;
if(str.length > $.passy.requirements.length.max) return false;
for(var i in $.passy.character) {
if($.passy.requirements.characters & $.passy.character[i]) {
valid = $.passy.contains(str, $.passy.character[i]) && valid;
}
}
return valid;
};
var methods = {
init: function(callback) {
var $this = $(this);
$this.on('change keyup', function() {
if(typeof callback !== 'function') return;
var value = $this.val();
callback.call($this, $.passy.analize(value), methods.valid.call($this));
});
},
generate: function(len) {
this.val($.passy.generate(len));
this.change();
},
valid: function() {
return $.passy.valid(this.val());
}
};
$.fn.passy = function(opt) {
if(methods[opt]) {
return methods[opt].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof opt === 'function' || !opt) {
return methods.init.apply(this, arguments);
}
return this;
};
$.extend({ passy: passy });
})(jQuery);

View File

@@ -0,0 +1,7 @@
Copyright (c) 2012 Scott Jehl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,75 @@
/*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license */
(function(){
// Bail out for browsers that have addListener support
if (window.matchMedia && window.matchMedia('all').addListener) {
return false;
}
var localMatchMedia = window.matchMedia,
hasMediaQueries = localMatchMedia('only all').matches,
isListening = false,
timeoutID = 0, // setTimeout for debouncing 'handleChange'
queries = [], // Contains each 'mql' and associated 'listeners' if 'addListener' is used
handleChange = function(evt) {
// Debounce
clearTimeout(timeoutID);
timeoutID = setTimeout(function() {
for (var i = 0, il = queries.length; i < il; i++) {
var mql = queries[i].mql,
listeners = queries[i].listeners || [],
matches = localMatchMedia(mql.media).matches;
// Update mql.matches value and call listeners
// Fire listeners only if transitioning to or from matched state
if (matches !== mql.matches) {
mql.matches = matches;
for (var j = 0, jl = listeners.length; j < jl; j++) {
listeners[j].call(window, mql);
}
}
}
}, 30);
};
window.matchMedia = function(media) {
var mql = localMatchMedia(media),
listeners = [],
index = 0;
mql.addListener = function(listener) {
// Changes would not occur to css media type so return now (Affects IE <= 8)
if (!hasMediaQueries) {
return;
}
// Set up 'resize' listener for browsers that support CSS3 media queries (Not for IE <= 8)
// There should only ever be 1 resize listener running for performance
if (!isListening) {
isListening = true;
window.addEventListener('resize', handleChange, true);
}
// Push object only if it has not been pushed already
if (index === 0) {
index = queries.push({
mql : mql,
listeners : listeners
});
}
listeners.push(listener);
};
mql.removeListener = function(listener) {
for (var i = 0, il = listeners.length; i < il; i++){
if (listeners[i] === listener){
listeners.splice(i, 1);
}
}
};
return mql;
};
}());

View File

@@ -0,0 +1,46 @@
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
window.matchMedia || (window.matchMedia = function() {
"use strict";
// For browsers that support matchMedium api such as IE 9 and webkit
var styleMedia = (window.styleMedia || window.media);
// For those that don't support matchMedium
if (!styleMedia) {
var style = document.createElement('style'),
script = document.getElementsByTagName('script')[0],
info = null;
style.type = 'text/css';
style.id = 'matchmediajs-test';
script.parentNode.insertBefore(style, script);
// 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
styleMedia = {
matchMedium: function(media) {
var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
// 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
if (style.styleSheet) {
style.styleSheet.cssText = text;
} else {
style.textContent = text;
}
// Test if media query is true or false
return info.width === '1px';
}
};
}
return function(media) {
return {
matches: styleMedia.matchMedium(media || 'all'),
media: media || 'all'
};
};
}());

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2009-2015
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,46 @@
nvd3.js License
Copyright (c) 2011-2014 Novus Partners, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
d3.js License
Copyright (c) 2012, Michael Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name Michael Bostock may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2011-2015 Twitter, Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because one or more lines are too long