Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap
This commit is contained in:
+118
-120
@@ -22,127 +22,115 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(document).ready( function () {
|
// This variables are defined in the dashboard view.tpl
|
||||||
|
// dashboard_ajax_url
|
||||||
$('#calendar_form input[type="submit"]').on('click', function (elt) {
|
// adminstats_ajax_url
|
||||||
setDashboardDateRange(elt.currentTarget.name);
|
// no_results_translation
|
||||||
return false;
|
// dashboard_use_push
|
||||||
});
|
// read_more
|
||||||
$(".preactivationLink").click(function() {
|
|
||||||
preactivationLinkClick($(this).attr("rel"));
|
|
||||||
});
|
|
||||||
|
|
||||||
refreshDashboard(false, false);
|
|
||||||
getBlogRss();
|
|
||||||
bindSubmitDashConfig();
|
|
||||||
bindCancelDashConfig();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
function refreshDashboard(module_name, use_push, extra)
|
|
||||||
{
|
|
||||||
module_list = new Array();
|
|
||||||
|
|
||||||
if (module_name === false)
|
|
||||||
{
|
|
||||||
$('.widget').each( function () {
|
|
||||||
module_list.push($(this).attr('id'));
|
|
||||||
if (!use_push)
|
|
||||||
$(this).addClass('loading');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
module_list.push(module_name);
|
|
||||||
if (!use_push)
|
|
||||||
$('#'+module_name+' section').each( function (){
|
|
||||||
$(this).addClass('loading');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var module_id in module_list)
|
|
||||||
{
|
|
||||||
if (use_push && !$('#'+module_list[module_id]).hasClass('allow_push'))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
function refreshDashboard(module_name, use_push, extra) {
|
||||||
|
var module_list = [];
|
||||||
|
this.getWidget = function(module_id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : dashboard_ajax_url,
|
url : dashboard_ajax_url,
|
||||||
data : {
|
data : {
|
||||||
ajax:true,
|
ajax: true,
|
||||||
action:'refreshDashboard',
|
action:'refreshDashboard',
|
||||||
module:module_list[module_id],
|
module: module_list[module_id],
|
||||||
dashboard_use_push:Number(use_push),
|
dashboard_use_push: Number(use_push),
|
||||||
extra:extra
|
extra: extra
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success : function(widgets){
|
success : function(widgets){
|
||||||
for (var widget_name in widgets)
|
for (var widget_name in widgets) {
|
||||||
for (data_type in widgets[widget_name])
|
for (var data_type in widgets[widget_name]) {
|
||||||
window[data_type](widget_name, widgets[widget_name][data_type]);
|
window[data_type](widget_name, widgets[widget_name][data_type]);
|
||||||
|
}
|
||||||
if (parseInt(dashboard_use_push) == 1)
|
}
|
||||||
|
if (parseInt(dashboard_use_push) === 1) {
|
||||||
refreshDashboard(false, true);
|
refreshDashboard(false, true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
contentType: 'application/json'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (module_name === false) {
|
||||||
|
$('.widget').each( function () {
|
||||||
|
module_list.push($(this).attr('id'));
|
||||||
|
if (!use_push) {
|
||||||
|
$(this).addClass('loading');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
module_list.push(module_name);
|
||||||
|
if (!use_push) {
|
||||||
|
$('#'+module_name+' section').each( function (){
|
||||||
|
$(this).addClass('loading');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var module_id in module_list) {
|
||||||
|
if (use_push && !$('#'+module_list[module_id]).hasClass('allow_push')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.getWidget(module_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDashboardDateRange(action)
|
function setDashboardDateRange(action) {
|
||||||
{
|
|
||||||
$('#datepickerFrom, #datepickerTo').parent('.input-group').removeClass('has-error');
|
$('#datepickerFrom, #datepickerTo').parent('.input-group').removeClass('has-error');
|
||||||
data = 'ajax=true&action=setDashboardDateRange&submitDatePicker=true&'+$('#calendar_form').serialize()+'&'+action+'=1';
|
var data = 'ajax=true&action=setDashboardDateRange&submitDatePicker=true&'+$('#calendar_form').serialize()+'&'+action+'=1';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : adminstats_ajax_url,
|
url : adminstats_ajax_url,
|
||||||
data : data,
|
data : data,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
success : function(jsonData){
|
success : function(jsonData){
|
||||||
if (!jsonData.has_errors)
|
if (!jsonData.has_errors) {
|
||||||
{
|
|
||||||
refreshDashboard(false, false);
|
refreshDashboard(false, false);
|
||||||
$('#datepickerFrom').val(jsonData.date_from);
|
$('#datepickerFrom').val(jsonData.date_from);
|
||||||
$('#datepickerTo').val(jsonData.date_to);
|
$('#datepickerTo').val(jsonData.date_to);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
$('#datepickerFrom, #datepickerTo').parent('.input-group').addClass('has-error');
|
$('#datepickerFrom, #datepickerTo').parent('.input-group').addClass('has-error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function data_value(widget_name, data)
|
function data_value(widget_name, data) {
|
||||||
{
|
for (var data_id in data) {
|
||||||
for (var data_id in data)
|
|
||||||
{
|
|
||||||
$('#'+data_id+' ').html(data[data_id]);
|
$('#'+data_id+' ').html(data[data_id]);
|
||||||
$('#'+data_id+', #'+widget_name).closest('section').removeClass('loading');
|
$('#'+data_id+', #'+widget_name).closest('section').removeClass('loading');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function data_trends(widget_name, data)
|
function data_trends(widget_name, data) {
|
||||||
{
|
for (var data_id in data) {
|
||||||
for (var data_id in data)
|
this.el = $('#'+data_id);
|
||||||
{
|
this.el.html(data[data_id].value);
|
||||||
$('#'+data_id).html(data[data_id]['value']);
|
if (data[data_id].way === 'up') {
|
||||||
if (data[data_id]['way'] == 'up')
|
this.el.parent().removeClass('dash_trend_down').removeClass('dash_trend_right').addClass('dash_trend_up');
|
||||||
$('#'+data_id).parent().removeClass('dash_trend_down').removeClass('dash_trend_right').addClass('dash_trend_up');
|
}
|
||||||
else if (data[data_id]['way'] == 'down')
|
else if (data[data_id].way === 'down') {
|
||||||
$('#'+data_id).parent().removeClass('dash_trend_up').removeClass('dash_trend_right').addClass('dash_trend_down');
|
this.el.parent().removeClass('dash_trend_up').removeClass('dash_trend_right').addClass('dash_trend_down');
|
||||||
else
|
}
|
||||||
$('#'+data_id).parent().removeClass('dash_trend_down').removeClass('dash_trend_up').addClass('dash_trend_right');
|
else {
|
||||||
$('#'+data_id).closest('section').removeClass('loading');
|
this.el.parent().removeClass('dash_trend_down').removeClass('dash_trend_up').addClass('dash_trend_right');
|
||||||
|
}
|
||||||
|
this.el.closest('section').removeClass('loading');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function data_table(widget_name, data)
|
function data_table(widget_name, data) {
|
||||||
{
|
for (var data_id in data) {
|
||||||
for (var data_id in data)
|
|
||||||
{
|
|
||||||
//fill header
|
//fill header
|
||||||
tr = '<tr>';
|
var tr = '<tr>';
|
||||||
for (var header in data[data_id].header)
|
for (var header in data[data_id].header) {
|
||||||
{
|
var head = data[data_id].header[header];
|
||||||
head = data[data_id].header[header];
|
var th = '<th '+ (head.class ? ' class="'+head.class+'" ' : '' )+ ' '+(head.id ? ' id="'+head.id+'" ' : '' )+'>';
|
||||||
th = '<th '+ (head.class ? ' class="'+head.class+'" ' : '' )+ ' '+(head.id ? ' id="'+head.id+'" ' : '' )+'>';
|
|
||||||
th += (head.wrapper_start ? ' '+head.wrapper_start+' ' : '' );
|
th += (head.wrapper_start ? ' '+head.wrapper_start+' ' : '' );
|
||||||
th += head.title;
|
th += head.title;
|
||||||
th += (head.wrapper_stop ? ' '+head.wrapper_stop+' ' : '' );
|
th += (head.wrapper_stop ? ' '+head.wrapper_stop+' ' : '' );
|
||||||
@@ -154,14 +142,12 @@ function data_table(widget_name, data)
|
|||||||
|
|
||||||
//fill body
|
//fill body
|
||||||
$('#'+data_id+' tbody').html('');
|
$('#'+data_id+' tbody').html('');
|
||||||
if (data[data_id].body.length)
|
if (data[data_id].body.length) {
|
||||||
for (var body_content_id in data[data_id].body)
|
for (var body_content_id in data[data_id].body) {
|
||||||
{
|
|
||||||
tr = '<tr>';
|
tr = '<tr>';
|
||||||
for (var body_content in data[data_id].body[body_content_id])
|
for (var body_content in data[data_id].body[body_content_id]) {
|
||||||
{
|
var body = data[data_id].body[body_content_id][body_content];
|
||||||
body = data[data_id].body[body_content_id][body_content];
|
var td = '<td '+ (body.class ? ' class="'+body.class+'" ' : '' )+ ' '+(body.id ? ' id="'+body.id+'" ' : '' )+'>';
|
||||||
td = '<td '+ (body.class ? ' class="'+body.class+'" ' : '' )+ ' '+(body.id ? ' id="'+body.id+'" ' : '' )+'>';
|
|
||||||
td += (body.wrapper_start ? ' '+body.wrapper_start+' ' : '' );
|
td += (body.wrapper_start ? ' '+body.wrapper_start+' ' : '' );
|
||||||
td += body.value;
|
td += body.value;
|
||||||
td += (body.wrapper_stop ? ' '+body.wrapper_stop+' ' : '' );
|
td += (body.wrapper_stop ? ' '+body.wrapper_stop+' ' : '' );
|
||||||
@@ -171,41 +157,42 @@ function data_table(widget_name, data)
|
|||||||
tr += '</tr>';
|
tr += '</tr>';
|
||||||
$('#'+data_id+' tbody').append(tr);
|
$('#'+data_id+' tbody').append(tr);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
$('#'+data_id+' tbody').html('<tr><td class="text-center" colspan="'+data[data_id].header.length+'">'+no_results_translation+'</td></tr>');
|
$('#'+data_id+' tbody').html('<tr><td class="text-center" colspan="'+data[data_id].header.length+'">'+no_results_translation+'</td></tr>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function data_chart(widget_name, charts)
|
function data_chart(widget_name, charts) {
|
||||||
{
|
for (var chart_id in charts) {
|
||||||
for (chart_id in charts)
|
|
||||||
window[charts[chart_id].chart_type](widget_name, charts[chart_id]);
|
window[charts[chart_id].chart_type](widget_name, charts[chart_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function data_list_small(widget_name, data)
|
function data_list_small(widget_name, data) {
|
||||||
{
|
|
||||||
for (var data_id in data)
|
for (var data_id in data)
|
||||||
{
|
{
|
||||||
$('#'+data_id).html('');
|
$('#'+data_id).html('');
|
||||||
for (var item in data[data_id])
|
for (var item in data[data_id]) {
|
||||||
$('#'+data_id).append('<li><span class="data_label">'+item+'</span><span class="data_value size_s">'+data[data_id][item]+'</span></li>');
|
$('#'+data_id).append('<li><span class="data_label">'+item+'</span><span class="data_value size_s">'+data[data_id][item]+'</span></li>');
|
||||||
|
}
|
||||||
$('#'+data_id+', #'+widget_name).closest('section').removeClass('loading');
|
$('#'+data_id+', #'+widget_name).closest('section').removeClass('loading');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBlogRss()
|
function getBlogRss() {
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : dashboard_ajax_url,
|
url : dashboard_ajax_url,
|
||||||
data : {
|
data : {
|
||||||
ajax:true,
|
ajax:true,
|
||||||
action:'getBlogRss'
|
action:'getBlogRss'
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success : function(jsonData){
|
success : function(jsonData) {
|
||||||
if (!jsonData.has_errors) {
|
if (!jsonData.has_errors) {
|
||||||
for (var article in jsonData.rss) {
|
for (var article in jsonData.rss) {
|
||||||
article_html = '<article><h4><a href="'+jsonData.rss[article].link+'">'+jsonData.rss[article].title+'</a></h4><span class="dash-news-date text-muted">'+jsonData.rss[article].date+'</span><p>'+jsonData.rss[article].short_desc+' <a href="'+jsonData.rss[article].link+'">'+read_more+'</a><p></article><hr/>';
|
var article_html = '<article><h4><a href="'+jsonData.rss[article].link+'">'+jsonData.rss[article].title+'</a></h4><span class="dash-news-date text-muted">'+jsonData.rss[article].date+'</span><p>'+jsonData.rss[article].short_desc+' <a href="'+jsonData.rss[article].link+'">'+read_more+'</a><p></article><hr/>';
|
||||||
$('.dash_news .dash_news_content').append(article_html);
|
$('.dash_news .dash_news_content').append(article_html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,8 +203,7 @@ function getBlogRss()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDashConfig(widget)
|
function toggleDashConfig(widget) {
|
||||||
{
|
|
||||||
if ($('#'+widget+' section.dash_config').hasClass('hide'))
|
if ($('#'+widget+' section.dash_config').hasClass('hide'))
|
||||||
{
|
{
|
||||||
$('#'+widget+' section').not('.dash_config').slideUp(500, function () {
|
$('#'+widget+' section').not('.dash_config').slideUp(500, function () {
|
||||||
@@ -228,37 +214,34 @@ function toggleDashConfig(widget)
|
|||||||
{
|
{
|
||||||
$('#'+widget+' section.dash_config').slideUp(500, function () {
|
$('#'+widget+' section.dash_config').slideUp(500, function () {
|
||||||
$('#'+widget+' section').not('.dash_config').slideDown(500).removeClass('hide');
|
$('#'+widget+' section').not('.dash_config').slideDown(500).removeClass('hide');
|
||||||
$('#'+widget+' section.dash_config').addClass('hide')
|
$('#'+widget+' section.dash_config').addClass('hide');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindSubmitDashConfig()
|
function bindSubmitDashConfig() {
|
||||||
{
|
|
||||||
$('.submit_dash_config').on('click', function () {
|
$('.submit_dash_config').on('click', function () {
|
||||||
saveDashConfig($(this).closest('section.widget').attr('id'));
|
saveDashConfig($(this).closest('section.widget').attr('id'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindCancelDashConfig()
|
function bindCancelDashConfig() {
|
||||||
{
|
|
||||||
$('.cancel_dash_config').on('click', function () {
|
$('.cancel_dash_config').on('click', function () {
|
||||||
toggleDashConfig($(this).closest('section.widget').attr('id'));
|
toggleDashConfig($(this).closest('section.widget').attr('id'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveDashConfig(widget_name)
|
function saveDashConfig(widget_name) {
|
||||||
{
|
var configs = '';
|
||||||
configs = '';
|
|
||||||
$('#'+widget_name+' form input, #'+widget_name+' form textarea , #'+widget_name+' form select').each( function () {
|
$('#'+widget_name+' form input, #'+widget_name+' form textarea , #'+widget_name+' form select').each( function () {
|
||||||
if ($(this).attr('type') == 'radio' && !$(this).attr('checked'))
|
if ($(this).attr('type') === 'radio' && !$(this).attr('checked')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
configs += '&configs['+$(this).attr('name')+']='+$(this).val();
|
configs += '&configs['+$(this).attr('name')+']='+$(this).val();
|
||||||
});
|
});
|
||||||
data = 'ajax=true&action=saveDashConfig&module='+widget_name+configs+'&hook='+$('#'+widget_name).closest('[id^=hook]').attr('id');
|
var data = 'ajax=true&action=saveDashConfig&module='+widget_name+configs+'&hook='+$('#'+widget_name).closest('[id^=hook]').attr('id');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : dashboard_ajax_url,
|
url : dashboard_ajax_url,
|
||||||
data : data,
|
data : data,
|
||||||
@@ -275,19 +258,34 @@ function saveDashConfig(widget_name)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function preactivationLinkClick(module)
|
function preactivationLinkClick(module) {
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : adminstats_ajax_url,
|
url : adminstats_ajax_url,
|
||||||
data : {
|
data : {
|
||||||
ajax : "1",
|
ajax : "1",
|
||||||
controller : "AdminDashboard",
|
controller : "AdminDashboard",
|
||||||
action : "savePreactivationRequest",
|
action : "savePreactivationRequest",
|
||||||
module : module,
|
module : module,
|
||||||
},
|
},
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
success : function(jsonData){
|
success : function(jsonData){
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(document).ready( function () {
|
||||||
|
$('#calendar_form input[type="submit"]').on('click', function(elt) {
|
||||||
|
elt.preventDefault();
|
||||||
|
setDashboardDateRange(elt.currentTarget.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".preactivationLink").on('click', function() {
|
||||||
|
preactivationLinkClick($(this).attr("rel"));
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshDashboard(false, false);
|
||||||
|
getBlogRss();
|
||||||
|
bindSubmitDashConfig();
|
||||||
|
bindCancelDashConfig();
|
||||||
|
});
|
||||||
@@ -102,11 +102,11 @@ Date.prototype.format = function(format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if (date_subtitle === undefined)
|
if (typeof date_subtitle === "undefined")
|
||||||
date_subtitle = '(from %s to %s)';
|
var date_subtitle = '(from %s to %s)';
|
||||||
|
|
||||||
if (date_format === undefined)
|
if (typeof date_format === "undefined")
|
||||||
date_format = 'Y-m-d';
|
var date_format = 'Y-m-d';
|
||||||
|
|
||||||
$('#date-start').change(function() {
|
$('#date-start').change(function() {
|
||||||
start = Date.parseDate($('#date-start').val(), 'Y-m-d');
|
start = Date.parseDate($('#date-start').val(), 'Y-m-d');
|
||||||
|
|||||||
Reference in New Issue
Block a user