Conflicts:
	templates/admin/default/admin-layout.tpl
This commit is contained in:
franck
2013-09-10 15:46:51 +02:00
599 changed files with 40518 additions and 3685 deletions

View File

@@ -227,15 +227,14 @@
{block name="after-javascript-include"}{/block}
{javascripts file='assets/js/bootstrap/bootstrap.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{block name="javascript-initialization"}{/block}
{debugbar_render}
{* Modules scripts are included now *}
{module_include location='footer_js'}
{debugbar_render}
{javascripts file='assets/js/bootstrap/bootstrap.js'}
<script src="{$asset_url}"></script>
{/javascripts}
</body>
</html>

View File

@@ -0,0 +1,474 @@
/* =========================================================
* 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.
* ========================================================= */
!function( $ ) {
// Picker object
var Datepicker = function(element, options){
this.element = $(element);
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
this.picker = $(DPGlobal.template)
.appendTo('body')
.on({
click: $.proxy(this.click, this)//,
//mousedown: $.proxy(this.mousedown, this)
});
this.isInput = this.element.is('input');
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
if (this.isInput) {
this.element.on({
focus: $.proxy(this.show, this),
//blur: $.proxy(this.hide, this),
keyup: $.proxy(this.update, this)
});
} else {
if (this.component){
this.component.on('click', $.proxy(this.show, this));
} else {
this.element.on('click', $.proxy(this.show, 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();
};
Datepicker.prototype = {
constructor: Datepicker,
show: function(e) {
this.picker.show();
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
this.place();
$(window).on('resize', $.proxy(this.place, this));
if (e ) {
e.stopPropagation();
e.preventDefault();
}
if (!this.isInput) {
}
var that = this;
$(document).on('mousedown', function(ev){
if ($(ev.target).closest('.datepicker').length == 0) {
that.hide();
}
});
this.element.trigger({
type: 'show',
date: this.date
});
},
hide: function(){
this.picker.hide();
$(window).off('resize', this.place);
this.viewMode = this.startViewMode;
this.showMode();
if (!this.isInput) {
$(document).off('mousedown', this.hide);
}
//this.set();
this.element.trigger({
type: 'hide',
date: this.date
});
},
set: function() {
var formated = DPGlobal.formatDate(this.date, this.format);
if (!this.isInput) {
if (this.component){
this.element.find('input').prop('value', formated);
}
this.element.data('date', formated);
} else {
this.element.prop('value', formated);
}
},
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();
},
place: function(){
var offset = this.component ? this.component.offset() : this.element.offset();
this.picker.css({
top: offset.top + this.height,
left: offset.left
});
},
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('.datepicker-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('.datepicker-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('.datepicker-days th:eq(1)')
.text(DPGlobal.dates.months[month]+' '+year);
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 (prevMonth.valueOf() === currentDate) {
clsName += ' active';
}
html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
if (prevMonth.getDay() === this.weekEnd) {
html.push('</tr>');
}
prevMonth.setDate(prevMonth.getDate()+1);
}
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
var currentYear = this.date.getFullYear();
var months = this.picker.find('.datepicker-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('.datepicker-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);
},
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 '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.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':
if (target.is('.day') && !target.is('.disabled')){
var day = parseInt(target.text(), 10)||1;
var month = this.viewDate.getMonth();
if (target.is('.old')) {
month -= 1;
} else if (target.is('.new')) {
month += 1;
}
var year = this.viewDate.getFullYear();
this.date = new Date(year, month, day,0,0,0,0);
this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
this.fill();
this.set();
this.element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
}
break;
}
}
},
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('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
}
};
$.fn.datepicker = function ( option, val ) {
return this.each(function () {
var $this = $(this),
data = $this.data('datepicker'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
}
if (typeof option === 'string') data[option](val);
});
};
$.fn.datepicker.defaults = {
onRender: function(date) {
return '';
}
};
$.fn.datepicker.Constructor = Datepicker;
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':
year = 2000 + val;
date.setFullYear(2000 + val);
break;
case 'yyyy':
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),
yyyy: date.getFullYear()
};
val.dd = (val.d < 10 ? '0' : '') + val.d;
val.mm = (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">&lsaquo;</th>'+
'<th colspan="5" class="switch"></th>'+
'<th class="next">&rsaquo;</th>'+
'</tr>'+
'</thead>',
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
};
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
'<div class="datepicker-days">'+
'<table class=" table-condensed">'+
DPGlobal.headTemplate+
'<tbody></tbody>'+
'</table>'+
'</div>'+
'<div class="datepicker-months">'+
'<table class="table-condensed">'+
DPGlobal.headTemplate+
DPGlobal.contTemplate+
'</table>'+
'</div>'+
'<div class="datepicker-years">'+
'<table class="table-condensed">'+
DPGlobal.headTemplate+
DPGlobal.contTemplate+
'</table>'+
'</div>'+
'</div>';
}( window.jQuery );

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,486 @@
/*
json2.js
2013-05-26
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== 'object') {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());

View File

@@ -0,0 +1,157 @@
(function($, window, document){
$(function(){
// -- Init datepicker --
if($('.date').length){
//$('.date').datepicker();
}
// -- Init tablesorter --
/*if($('.tablesorter').length){
$('.tablesorter').tablesorter({
widgets: ["filter", "stickyHeaders"],
widthFixed : false,
widgetOptions : {
filter_cssFilter : 'input-medium form-control',
filter_formatter : {
2 : function($cell, indx){
return $.tablesorter.filterFormatter.uiDateCompare( $cell, indx, {
dateFormat: "dd/mm/yy",
changeMonth : true,
changeYear : true,
compare : '='
});
},
3 : function($cell, indx){
return $.tablesorter.filterFormatter.uiRange( $cell, indx, {
value: 1,
min: 1,
max: 50,
delayed: true,
valueToHeader: false,
exactMatch: false
});
}
}
}
});
}*/
// -- Effect description
if($('[name=effect]').length){
var $effectSelect = $('[name=effect]'),
$helpBlock = $effectSelect.next('.help-block');
$effectSelect.change(function(){
var description = $(this).find(":selected").data('description');
$helpBlock.text(description);
});
}
// -- Max usage --
if($('#is-unlimited').length){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
$('#is-unlimited').change(function(){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
else{
$('#max-usage').show().val('').attr('value', '');
}
});
}
// -- Confirm Box --
if($('[data-toggle="confirm"]').length){
$('[data-toggle="confirm"]').click(function(e){
var $link = $(this);
var modal = $(this).data('target');
$(modal).modal('show');
$(modal).on('shown', function () {
$('[data-confirm]').attr('href', $link.attr('href'));
});
if($(modal).is(':hidden')){
e.preventDefault();
}
});
}
// -- Mini browser --
miniBrowser = function (root, url){
$.getJSON(url, {
root: root
})
.done(function(data) {
var resultat = data;
var breadcrumb = $('<div />');
$(resultat.breadcrumb).each(function(k, v){
breadcrumb.append(
$('<span />').html(' > '),
$('<a />').attr('href', '#').html(v.display).click(function(e){
e.preventDefault();
miniBrowser(v.url);
})
);
});
var categories = $('<div />');
$(resultat.categories).each(function(k, v){
categories.append(
$('<p />').append(
$('<a />').attr('href', '#').html(v.titre).click(function(e){
e.preventDefault();
miniBrowser(v.id);
})
)
);
});
var products = $('<div />');
$(resultat.products).each(function(k, v){
products.append(
$('<p />').append(
$('<a />').attr('href', '#').html(v.titre).click(function(e){
e.preventDefault();
$('#productToAdd_ref').val(v.ref);
$('#productToAdd_titre').val(v.titre);
$('#productToAdd_quantite').val(1);
manageStock(v.variants, v.promo?v.prix2:v.prix);
$('#productToAdd_tva').val(v.tva);
$('.productToAddInformation').show();
$('#btn_ajout_produit').show();
})
)
);
});
$('#minibrowser-breadcrumb').unbind().empty().append(breadcrumb);
$('#minibrowser-categories').unbind().empty().append(categories);
})
.fail(function() {
console.log('An error occurred while reading from JSON file');
});
}
});
}(window.jQuery, window, document));

View File

@@ -0,0 +1,116 @@
/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
* in the JSON will become a property of the element itself.
*
* There are three supported types of metadata storage:
*
* attr: Inside an attribute. The name parameter indicates *which* attribute.
*
* class: Inside the class attribute, wrapped in curly braces: { }
*
* elem: Inside a child element (e.g. a script tag). The
* name parameter indicates *which* element.
*
* The metadata for an element is loaded the first time the element is accessed via jQuery.
*
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
*
* @name $.metadata.setType
*
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("class")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from the class attribute
*
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("attr", "data")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a "data" attribute
*
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
* @before $.metadata.setType("elem", "script")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a nested script element
*
* @param String type The encoding type
* @param String name The name of the attribute to be used to get metadata (optional)
* @cat Plugins/Metadata
* @descr Sets the type of encoding to be used when loading metadata for the first time
* @type undefined
* @see metadata()
*/
(function($) {
$.extend({
metadata : {
defaults : {
type: 'class',
name: 'metadata',
cre: /(\{.*\})/,
single: 'metadata'
},
setType: function( type, name ){
this.defaults.type = type;
this.defaults.name = name;
},
get: function( elem, opts ){
var data, m, e, attr,
settings = $.extend({},this.defaults,opts);
// check for empty string in single property
if ( !settings.single.length ) { settings.single = 'metadata'; }
data = $.data(elem, settings.single);
// returned cached data if it already exists
if ( data ) { return data; }
data = "{}";
if ( settings.type === "class" ) {
m = settings.cre.exec( elem.className );
if ( m ) { data = m[1]; }
} else if ( settings.type === "elem" ) {
if( !elem.getElementsByTagName ) { return undefined; }
e = elem.getElementsByTagName(settings.name);
if ( e.length ) { data = $.trim(e[0].innerHTML); }
} else if ( elem.getAttribute !== undefined ) {
attr = elem.getAttribute( settings.name );
if ( attr ) { data = attr; }
}
if ( data.indexOf( '{' ) <0 ) { data = "{" + data + "}"; }
data = eval("(" + data + ")");
$.data( elem, settings.single, data );
return data;
}
}
});
/**
* Returns the metadata object for the first member of the jQuery object.
*
* @name metadata
* @descr Returns element's metadata object
* @param Object opts An object contianing settings to override the defaults
* @type jQuery
* @cat Plugins/Metadata
*/
$.fn.metadata = function( opts ){
return $.metadata.get( this[0], opts );
};
})(jQuery);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,826 @@
/*! Filter widget formatter functions - updated 6/4/2013
* requires: tableSorter 2.7.7+ and jQuery 1.4.3+
*
* uiSpinner (jQuery UI spinner)
* uiSlider (jQuery UI slider)
* uiRange (jQuery UI range slider)
* uiDateCompare (jQuery UI datepicker; 1 input)
* uiDatepicker (jQuery UI datepicker; 2 inputs, filter range)
* html5Number (spinner)
* html5Range (slider)
* html5Color (color)
*/
/*jshint browser:true, jquery:true, unused:false */
/*global jQuery: false */
;(function($){
"use strict";
$.tablesorter = $.tablesorter || {};
$.tablesorter.filterFormatter = {
/**********************\
jQuery UI Spinner
\**********************/
uiSpinner: function($cell, indx, spinnerDef) {
var o = $.extend({
min : 0,
max : 100,
step : 1,
value : 1,
delayed : true,
addToggle : true,
disabled : false,
exactMatch : true,
compare : ''
}, spinnerDef ),
// Add a hidden input to hold the range values
$input = $('<input class="filter" type="hidden">')
.appendTo($cell)
// hidden filter update (.tsfilter) namespace trigger by filter widget
.bind('change.tsfilter', function(){
updateSpinner({ value: this.value, delayed: false });
}),
$shcell = [],
c = $cell.closest('table')[0].config,
// this function updates the hidden input and adds the current values to the header cell text
updateSpinner = function(ui) {
var chkd = true, state,
// ui is not undefined on create
v = ui && ui.value && $.tablesorter.formatFloat((ui.value + '').replace(/[><=]/g,'')) || $cell.find('.spinner').val() || o.value;
if (o.addToggle) {
chkd = $cell.find('.toggle').is(':checked');
}
state = o.disabled || !chkd ? 'disable' : 'enable';
$cell.find('.filter')
// add equal to the beginning, so we filter exact numbers
.val( chkd ? (o.compare ? o.compare : o.exactMatch ? '=' : '') + v : '' )
.trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
.find('.spinner').spinner(state).val(v);
// update sticky header cell
if ($shcell.length) {
$shcell.find('.spinner').spinner(state).val(v);
if (o.addToggle) {
$shcell.find('.toggle')[0].checked = chkd;
}
}
};
// add callbacks; preserve added callbacks
o.oldcreate = o.create;
o.oldspin = o.spin;
o.create = function(event, ui) {
updateSpinner(); // ui is an empty object on create
if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
};
o.spin = function(event, ui) {
updateSpinner(ui);
if (typeof o.oldspin === 'function') { o.oldspin(event, ui); }
};
if (o.addToggle) {
$('<div class="button"><input id="uispinnerbutton' + indx + '" type="checkbox" class="toggle" /><label for="uispinnerbutton' + indx + '"></label></div>')
.appendTo($cell)
.find('.toggle')
.bind('change', function(){
updateSpinner();
});
}
// make sure we use parsed data
$cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
// add a jQuery UI spinner!
$('<input class="spinner spinner' + indx + '" />')
.val(o.value)
.appendTo($cell)
.spinner(o)
.bind('change keyup', function(e){
updateSpinner();
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
if (o.addToggle) {
$('<div class="button"><input id="stickyuispinnerbutton' + indx + '" type="checkbox" class="toggle" /><label for="stickyuispinnerbutton' + indx + '"></label></div>')
.appendTo($shcell)
.find('.toggle')
.bind('change', function(){
$cell.find('.toggle')[0].checked = this.checked;
updateSpinner();
});
}
// add a jQuery UI spinner!
$('<input class="spinner spinner' + indx + '" />')
.val(o.value)
.appendTo($shcell)
.spinner(o)
.bind('change keyup', function(e){
$cell.find('.spinner').val( this.value );
updateSpinner();
});
});
// on reset
c.$table.bind('filterReset', function(){
// turn off the toggle checkbox
if (o.addToggle) {
$cell.find('.toggle')[0].checked = false;
}
updateSpinner();
});
updateSpinner();
return $input;
},
/**********************\
jQuery UI Slider
\**********************/
uiSlider: function($cell, indx, sliderDef) {
var o = $.extend({
value : 0,
min : 0,
max : 100,
step : 1,
range : "min",
delayed : true,
valueToHeader : false,
exactMatch : true,
compare : '',
allText : 'all'
}, sliderDef ),
// Add a hidden input to hold the range values
$input = $('<input class="filter" type="hidden">')
.appendTo($cell)
// hidden filter update (.tsfilter) namespace trigger by filter widget
.bind('change.tsfilter', function(){
updateSlider({ value: this.value });
}),
$shcell = [],
c = $cell.closest('table')[0].config,
// this function updates the hidden input and adds the current values to the header cell text
updateSlider = function(ui) {
// ui is not undefined on create
var v = typeof ui !== "undefined" ? $.tablesorter.formatFloat((ui.value + '').replace(/[><=]/g,'')) || o.min : o.value,
val = o.compare ? v : v === o.min ? o.allText : v,
result = o.compare + val;
if (o.valueToHeader) {
// add range indication to the header cell above!
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
} else {
// add values to the handle data-value attribute so the css tooltip will work properly
$cell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
}
// update the hidden input;
// ****** ADD AN EQUAL SIGN TO THE BEGINNING! <- this makes the slide exactly match the number ******
// when the value is at the minimum, clear the hidden input so all rows will be seen
$cell.find('.filter')
.val( ( o.compare ? o.compare + v : v === o.min ? '' : (o.exactMatch ? '=' : '') + v ) )
.trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
.find('.slider').slider('value', v);
// update sticky header cell
if ($shcell.length) {
$shcell.find('.slider').slider('value', v);
if (o.valueToHeader) {
$shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
} else {
$shcell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
}
}
};
$cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
// add span to header for value - only works if the line in the updateSlider() function is also un-commented out
if (o.valueToHeader) {
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="curvalue" />');
}
// add callbacks; preserve added callbacks
o.oldcreate = o.create;
o.oldslide = o.slide;
o.create = function(event, ui) {
updateSlider(); // ui is an empty object on create
if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
};
o.slide = function(event, ui) {
updateSlider(ui);
if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
};
// add a jQuery UI slider!
$('<div class="slider slider' + indx + '"/>')
.appendTo($cell)
.slider(o);
// on reset
c.$table.bind('filterReset', function(){
$cell.find('.slider').slider('value', o.value);
updateSlider();
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
// add a jQuery UI slider!
$('<div class="slider slider' + indx + '"/>')
.val(o.value)
.appendTo($shcell)
.slider(o)
.bind('change keyup', function(e){
$cell.find('.slider').val( this.value );
updateSlider();
});
});
return $input;
},
/*************************\
jQuery UI Range Slider (2 handles)
\*************************/
uiRange: function($cell, indx, rangeDef) {
var o = $.extend({
values : [0, 100],
min : 0,
max : 100,
range : true,
delayed : true,
valueToHeader : false
}, rangeDef ),
// Add a hidden input to hold the range values
$input = $('<input class="filter" type="hidden">')
.appendTo($cell)
// hidden filter update (.tsfilter) namespace trigger by filter widget
.bind('change.tsfilter', function(){
var v = this.value.split(' - ');
if (this.value === '') { v = [ o.min, o.max ]; }
if (v && v[1]) {
updateUiRange({ values: v, delay: false });
}
}),
$shcell = [],
c = $cell.closest('table')[0].config,
// this function updates the hidden input and adds the current values to the header cell text
updateUiRange = function(ui) {
// ui.values are undefined for some reason on create
var val = ui && ui.values || o.values,
result = val[0] + ' - ' + val[1],
// make range an empty string if entire range is covered so the filter row will hide (if set)
range = val[0] === o.min && val[1] === o.max ? '' : result;
if (o.valueToHeader) {
// add range indication to the header cell above (if not using the css method)!
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
} else {
// add values to the handle data-value attribute so the css tooltip will work properly
$cell.find('.ui-slider-handle')
.addClass('value-popup')
.eq(0).attr('data-value', val[0]).end() // adding value to data attribute
.eq(1).attr('data-value', val[1]); // value popup shown via css
}
// update the hidden input
$cell.find('.filter').val(range)
.trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
.find('.range').slider('values', val);
// update sticky header cell
if ($shcell.length) {
$shcell.find('.range').slider('values', val);
if (o.valueToHeader) {
$shcell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
} else {
$shcell.find('.ui-slider-handle')
.addClass('value-popup')
.eq(0).attr('data-value', val[0]).end() // adding value to data attribute
.eq(1).attr('data-value', val[1]); // value popup shown via css
}
}
};
$cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
// add span to header for value - only works if the line in the updateUiRange() function is also un-commented out
if (o.valueToHeader) {
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="currange"/>');
}
// add callbacks; preserve added callbacks
o.oldcreate = o.create;
o.oldslide = o.slide;
// add a jQuery UI range slider!
o.create = function(event, ui) {
updateUiRange(); // ui is an empty object on create
if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
};
o.slide = function(event, ui) {
updateUiRange(ui);
if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
};
$('<div class="range range' + indx +'"/>')
.appendTo($cell)
.slider(o);
// on reset
c.$table.bind('filterReset', function(){
$cell.find('.range').slider('values', o.values);
updateUiRange();
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
// add a jQuery UI slider!
$('<div class="range range' + indx + '"/>')
.val(o.value)
.appendTo($shcell)
.slider(o)
.bind('change keyup', function(e){
$cell.find('.range').val( this.value );
updateUiRange();
});
});
// return the hidden input so the filter widget has a reference to it
return $input;
},
/*************************\
jQuery UI Datepicker compare (1 input)
\*************************/
uiDateCompare: function($cell, indx, defDate) {
var o = $.extend({
defaultDate : '',
cellText : '',
changeMonth : true,
changeYear : true,
numberOfMonths : 1,
compare : ''
}, defDate),
$hdr = $cell.closest('thead').find('th[data-column=' + indx + ']'),
// Add a hidden input to hold the range values
$input = $('<input class="dateCompare" type="hidden">')
.appendTo($cell)
// hidden filter update (.tsfilter) namespace trigger by filter widget
.bind('change.tsfilter', function(){
var v = this.value;
if (v) {
o.onClose(v);
}
}),
t, $shcell = [],
c = $cell.closest('table')[0].config;
// make sure we're using parsed dates in the search
$hdr.addClass('filter-parsed');
// Add date range picker
t = '<label>' + o.cellText + '</label><input type="text" class="date date' + indx +
'" placeholder="' + ($hdr.data('placeholder') || $hdr.attr('data-placeholder') || '') + '" />';
$(t).appendTo($cell);
// add callbacks; preserve added callbacks
o.oldonClose = o.onClose;
o.onClose = function( selectedDate, ui ) {
var date = new Date(selectedDate + ( o.compare.match('<') ? ' 23:59:59' : '' )).getTime() || '';
$cell
// update hidden input
.find('.dateCompare').val( o.compare + date )
.trigger('search').end()
.find('.date')
.datepicker('setDate', selectedDate);
// update sticky header cell
if ($shcell.length) {
$shcell.find('.date').datepicker('setDate', selectedDate);
}
if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
};
$cell.find('.date').datepicker(o);
if (o.filterDate) {
$cell.find('.date').datepicker('setDate', o.filterDate);
}
// on reset
c.$table.bind('filterReset', function(){
$cell.find('.date').val('').datepicker('option', 'currentText', '' );
if ($shcell.length) {
$shcell.find('.date').val('').datepicker('option', 'currentText', '' );
}
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
// add a jQuery datepicker!
$shcell
.append(t)
.find('.date')
.datepicker(o);
});
// return the hidden input so the filter widget has a reference to it
return $input.val( o.defaultDate ? o.defaultDate : '' );
},
/*************************\
jQuery UI Datepicker (2 inputs)
\*************************/
uiDatepicker: function($cell, indx, defDate) {
var o = $.extend({
from : '',
to : '',
textFrom : 'from',
textTo : 'to',
changeMonth : true,
changeYear : true,
numberOfMonths : 1
}, defDate),
t, closeFrom, $shcell = [],
// Add a hidden input to hold the range values
$input = $('<input class="dateRange" type="hidden">')
.appendTo($cell)
// hidden filter update (.tsfilter) namespace trigger by filter widget
.bind('change.tsfilter', function(){
var v = this.value;
if (v.match(' - ')) {
v = v.split(' - ');
$cell.find('.dateTo').val(v[1]);
closeFrom(v[0]);
} else if (v.match('>=')) {
closeFrom( v.replace('>=', '') );
} else if (v.match('<=')) {
o.onClose( v.replace('<=', '') );
}
}),
c = $cell.closest('table')[0].config;
// make sure we're using parsed dates in the search
$cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
// Add date range picker
t = '<label>' + o.textFrom + '</label><input type="text" class="dateFrom" /><label>' + o.textTo + '</label><input type="text" class="dateTo" />';
$(t).appendTo($cell);
// add callbacks; preserve added callbacks
o.oldonClose = o.onClose;
o.defaultDate = o.from || o.defaultDate;
closeFrom = o.onClose = function( selectedDate, ui ) {
var from = ( (new Date(selectedDate)).getTime() || ''),
to = (new Date($cell.find('.dateTo').val() + ' 23:59:59').getTime() || ''),
range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
$cell
.find('.dateTo').datepicker('option', 'minDate', selectedDate ).end()
.find('.dateFrom').val(selectedDate).end()
// update hidden input
.find('.dateRange').val(range)
.trigger('search');
// update sticky header cell
if ($shcell.length) {
$shcell
.find('.dateTo').datepicker('option', 'minDate', selectedDate ).end()
.find('.dateFrom').val(selectedDate);
}
if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
};
$cell.find('.dateFrom').datepicker(o);
o.defaultDate = o.to || '+7d'; // set to date +7 days from today (if not defined)
o.onClose = function( selectedDate, ui ) {
var from = new Date( $cell.find('.dateFrom').val() ).getTime() || '',
to = new Date( selectedDate + ' 23:59:59' ).getTime() || '',
range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
$cell
.find('.dateFrom').datepicker('option', 'maxDate', selectedDate ).end()
.find('.dateTo').val(selectedDate).end()
.find('.dateRange').val(range)
.trigger('search');
// update sticky header cell
if ($shcell.length) {
$shcell
.find('.dateFrom').datepicker('option', 'maxDate', selectedDate ).end()
.find('.dateTo').val(selectedDate);
}
if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
};
$cell.find('.dateTo').datepicker(o);
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
// add a jQuery datepicker!
$shcell.append(t).find('.dateTo').datepicker(o);
o.defaultDate = o.from || o.defaultDate || new Date();
o.onClose = closeFrom;
$shcell.find('.dateFrom').datepicker(o);
});
// on reset
$cell.closest('table').bind('filterReset', function(){
$cell.find('.dateFrom, .dateTo').val('');
if ($shcell.length) {
$shcell.find('.dateFrom, .dateTo').val('');
}
});
// return the hidden input so the filter widget has a reference to it
t = o.from ? ( o.to ? o.from + ' - ' + o.to : '>=' + o.from ) : (o.to ? '<=' + o.to : '');
return $input.val( t );
},
/**********************\
HTML5 Number (spinner)
\**********************/
html5Number : function($cell, indx, def5Num) {
var t, o = $.extend({
value : 0,
min : 0,
max : 100,
step : 1,
delayed : true,
disabled : false,
addToggle : true,
exactMatch : true,
compare : '',
skipTest: false
}, def5Num),
// test browser for HTML5 range support
$number = $('<input type="number" style="visibility:hidden;" value="test">').appendTo($cell),
// test if HTML5 number is supported - from Modernizr
numberSupported = o.skipTest || $number.attr('type') === 'number' && $number.val() !== 'test',
$shcell = [],
c = $cell.closest('table')[0].config,
updateNumber = function(v, delayed){
var chkd = o.addToggle ? $cell.find('.toggle').is(':checked') : true;
$cell.find('input[type=hidden]')
// add equal to the beginning, so we filter exact numbers
.val( !o.addToggle || chkd ? (o.compare ? o.compare : o.exactMatch ? '=' : '') + v : '' )
.trigger('search', delayed ? delayed : o.delayed).end()
.find('.number').val(v);
if ($cell.find('.number').length) {
$cell.find('.number')[0].disabled = (o.disabled || !chkd);
}
// update sticky header cell
if ($shcell.length) {
$shcell.find('.number').val(v)[0].disabled = (o.disabled || !chkd);
if (o.addToggle) {
$shcell.find('.toggle')[0].checked = chkd;
}
}
};
$number.remove();
if (numberSupported) {
t = o.addToggle ? '<div class="button"><input id="html5button' + indx + '" type="checkbox" class="toggle" /><label for="html5button' + indx + '"></label></div>' : '';
t += '<input class="number" type="number" min="' + o.min + '" max="' + o.max + '" value="' +
o.value + '" step="' + o.step + '" />';
// add HTML5 number (spinner)
$cell
.html(t + '<input type="hidden" />')
.find('.toggle, .number').bind('change', function(){
updateNumber( $cell.find('.number').val() );
})
.closest('thead').find('th[data-column=' + indx + ']')
.addClass('filter-parsed') // get exact numbers from column
// on reset
.closest('table').bind('filterReset', function(){
// turn off the toggle checkbox
if (o.addToggle) {
$cell.find('.toggle')[0].checked = false;
if ($shcell.length) {
$shcell.find('.toggle')[0].checked = false;
}
}
updateNumber( $cell.find('.number').val() );
});
// hidden filter update (.tsfilter) namespace trigger by filter widget
$cell.find('input[type=hidden]').bind('change.tsfilter', function(){
updateNumber( this.value );
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
$shcell
.html(t)
.find('.toggle, .number').bind('change', function(){
updateNumber( $shcell.find('.number').val() );
});
updateNumber( $cell.find('.number').val() );
});
updateNumber( $cell.find('.number').val() );
}
return numberSupported ? $cell.find('input[type="hidden"]') : $('<input type="search">');
},
/**********************\
HTML5 range slider
\**********************/
html5Range : function($cell, indx, def5Range) {
var t, o = $.extend({
value : 0,
min : 0,
max : 100,
step : 1,
delayed : true,
valueToHeader : true,
exactMatch : true,
compare : '',
allText : 'all',
skipTest : false
}, def5Range),
// test browser for HTML5 range support
$range = $('<input type="range" style="visibility:hidden;" value="test">').appendTo($cell),
// test if HTML5 range is supported - from Modernizr (but I left out the method to detect in Safari 2-4)
// see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/inputtypes.js
rangeSupported = o.skipTest || $range.attr('type') === 'range' && $range.val() !== 'test',
$shcell = [],
c = $cell.closest('table')[0].config,
updateRange = function(v, delayed){
/*jshint eqeqeq:false */
v = (v + '').replace(/[<>=]/g,'') || o.min; // hidden input changes may include compare symbols
var t = ' (' + (o.compare ? o.compare + v : v == o.min ? o.allText : v) + ')';
$cell.find('input[type=hidden]')
// add equal to the beginning, so we filter exact numbers
.val( ( o.compare ? o.compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) ) )
//( val == o.min ? '' : val + (o.exactMatch ? '=' : ''))
.trigger('search', delayed ? delayed : o.delayed).end()
.find('.range').val(v);
// or add current value to the header cell, if desired
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(t);
// update sticky header cell
if ($shcell.length) {
$shcell.find('.range').val(v);
$shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(t);
}
};
$range.remove();
if (rangeSupported) {
// add HTML5 range
$cell
.html('<input type="hidden"><input class="range" type="range" min="' + o.min + '" max="' + o.max + '" value="' + o.value + '" />')
.closest('thead').find('th[data-column=' + indx + ']')
.addClass('filter-parsed') // get exact numbers from column
// add span to header for the current slider value
.find('.tablesorter-header-inner').append('<span class="curvalue" />');
$cell.find('.range').bind('change', function(){
updateRange( this.value );
});
// hidden filter update (.tsfilter) namespace trigger by filter widget
$cell.find('input[type=hidden]').bind('change.tsfilter', function(){
/*jshint eqeqeq:false */
var v = this.value;
if (v !== this.lastValue) {
this.lastValue = ( o.compare ? o.compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) );
this.value = this.lastValue;
updateRange( v );
}
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
$shcell
.html('<input class="range" type="range" min="' + o.min + '" max="' + o.max + '" value="' + o.value + '" />')
.find('.range').bind('change', function(){
updateRange( $shcell.find('.range').val() );
});
updateRange( $cell.find('.range').val() );
});
// on reset
$cell.closest('table').bind('filterReset', function(){
// just turn off the colorpicker
updateRange(o.value);
});
updateRange( $cell.find('.range').val() );
}
return rangeSupported ? $cell.find('input[type="hidden"]') : $('<input type="search">');
},
/**********************\
HTML5 Color picker
\**********************/
html5Color: function($cell, indx, defColor) {
var t, o = $.extend({
value : '#000000',
disabled : false,
addToggle : true,
exactMatch : true,
valueToHeader : false,
skipTest : false
}, defColor),
// Add a hidden input to hold the range values
$color = $('<input type="color" style="visibility:hidden;" value="test">').appendTo($cell),
// test if HTML5 color is supported - from Modernizr
colorSupported = o.skipTest || $color.attr('type') === 'color' && $color.val() !== 'test',
$shcell = [],
c = $cell.closest('table')[0].config,
updateColor = function(v){
v = v || o.value;
var chkd = true,
t = ' (' + v + ')';
if (o.addToggle) {
chkd = $cell.find('.toggle').is(':checked');
}
if ($cell.find('.colorpicker').length) {
$cell.find('.colorpicker').val(v)[0].disabled = (o.disabled || !chkd);
}
$cell.find('input[type=hidden]')
.val( chkd ? v + (o.exactMatch ? '=' : '') : '' )
.trigger('search');
if (o.valueToHeader) {
// add current color to the header cell
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.curcolor').html(t);
} else {
// current color to span in cell
$cell.find('.currentColor').html(t);
}
// update sticky header cell
if ($shcell.length) {
$shcell.find('.colorpicker').val(v)[0].disabled = (o.disabled || !chkd);
if (o.addToggle) {
$shcell.find('.toggle')[0].checked = chkd;
}
if (o.valueToHeader) {
// add current color to the header cell
$shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curcolor').html(t);
} else {
// current color to span in cell
$shcell.find('.currentColor').html(t);
}
}
};
$color.remove();
if (colorSupported) {
// add HTML5 color picker
t = '<div class="color-controls-wrapper">';
t += o.addToggle ? '<div class="button"><input id="colorbutton' + indx + '" type="checkbox" class="toggle" /><label for="colorbutton' + indx + '"></label></div>' : '';
t += '<input type="hidden"><input class="colorpicker" type="color" />';
t += (o.valueToHeader ? '' : '<span class="currentColor">(#000000)</span>') + '</div>';
$cell.html(t);
// add span to header for the current color value - only works if the line in the updateColor() function is also un-commented out
if (o.valueToHeader) {
$cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="curcolor" />');
}
$cell.find('.toggle, .colorpicker').bind('change', function(){
updateColor( $cell.find('.colorpicker').val() );
});
// hidden filter update (.tsfilter) namespace trigger by filter widget
$cell.find('input[type=hidden]').bind('change.tsfilter', function(){
updateColor( this.value );
});
// on reset
$cell.closest('table').bind('filterReset', function(){
// just turn off the colorpicker
$cell.find('.toggle')[0].checked = false;
updateColor( $cell.find('.colorpicker').val() );
});
// has sticky headers?
c.$table.bind('stickyHeadersInit', function(){
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx);
$shcell
.html(t)
.find('.toggle, .colorpicker').bind('change', function(){
updateColor( $shcell.find('.colorpicker').val() );
});
updateColor( $shcell.find('.colorpicker').val() );
});
updateColor( o.value );
}
return colorSupported ? $cell.find('input[type="hidden"]') : $('<input type="search">');
}
};
})(jQuery);

File diff suppressed because it is too large Load Diff

View File

@@ -2,5 +2,4 @@
@import "bootstrap/bootstrap.less";
/* Thelia Admin */
@import "thelia/thelia.less";
// @import "thelia/responsive.less";
@import "thelia/thelia.less";

View File

@@ -247,4 +247,10 @@
.ui-slider{
margin-top: 23px;
}
.loading{
background: url("@{imgDir}/ajax-loader.gif") no-repeat;
height: 24px;
width: 24px;
}

View File

@@ -0,0 +1,41 @@
{extends file="admin-layout.tpl"}
{block name="check-permissions"}admin.coupon.create{/block}
{block name="page-title"}{intl l='Create coupon'}{/block}
{block name="main-content"}
<section id="wrapper" class="container">
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
</ul>
</nav>
<div class="page-header">
<h1>Coupons : <small>Add a coupon</small></h1>
</div>
{form name="thelia.admin.coupon.creation"}
{include file='coupon/form.html' formAction={url path={$formAction}}}
{/form}
</section> <!-- #wrapper -->
{include file='includes/confirmation-modal.html'}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/bootstrap-datepicker/js/bootstrap-datepicker.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function($){
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
});
</script>
{/block}

View File

@@ -0,0 +1,173 @@
{extends file="admin-layout.tpl"}
{block name="check-permissions"}admin.coupon.view{/block}
{block name="page-title"}{intl l='Coupons'}{/block}
{block name="main-content"}
<section id="wrapper" class="container">
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
</ul>
</nav>
<div class="page-header">
<h1>Coupons : <small>List of coupons</small></h1>
</div>
<section class="row">
<div class="col-md-12 general-block-decorator">
<table class="table table-striped tablesorter">
<caption>
List of enabled coupons
</caption>
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Expiration date</th>
<th>Usage left</th>
<th class="sorter-false filter-false">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>18/10/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>05/09/2013</td>
<td>20</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>03/12/2013</td>
<td>9</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>25/01/2013</td>
<td>4</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section class="row">
<div class="col-md-12 general-block-decorator">
<table class="table table-striped tablesorter">
<caption>
List of disabled coupons
</caption>
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Expiration date</th>
<th>Usage left</th>
<th class="sorter-false filter-false">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -30 &euro;</td>
<td>18/10/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -20 &euro;</td>
<td>05/09/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -50 &euro;</td>
<td>03/12/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -5 &euro;</td>
<td>25/01/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</section> <!-- #wrapper -->
{include file='includes/confirmation-modal.html' id="disable" message="{intl l='Do you really want to disable this element ?'}"}
{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/bootstrap-editable/js/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/tablesorter/jquery.tablesorter.min.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/tablesorter/jquery.metadata.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/tablesorter/jquery.tablesorter.widgets.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/tablesorter/jquery.tablesorter.widgets-filter-formatter.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{/block}

View File

@@ -0,0 +1,124 @@
{extends file="admin-layout.tpl"}
{block name="check-permissions"}admin.coupon.view{/block}
{block name="page-title"}{intl l='Coupon'}{/block}
{block name="main-content"}
<section id="wrapper" class="container">
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
</ul>
</nav>
{loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"}
<div class="page-header">
<h1>{intl l='Coupon : '}<small>#CODE</small></h1>
</div>
<section class="row">
<div class="col-md-12 general-block-decorator">
<div class="alert alert-info">
<span class="glyphicon glyphicon-question-sign"></span>
{if #IS_ENABLED}{else}{intl l='This coupon is disabled, you can enable to the bottom of this form.'}{/if}
</div>
<table class="table table-striped">
<tbody>
<tr>
<td>{intl l='Title'}</td>
<td>#TITLE</td>
</tr>
<tr>
<td>{intl l='Expiration date'}</td>
<td>#EXPIRATION_DATE</td>
</tr>
<tr>
<td>{intl l='Usage left'}</td>
<td>
{if #USAGE_LEFT}
<span class="label label-success">
#USAGE_LEFT
</span>
{else}
<span class="label label-important">
0
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">#SHORT_DESCRIPTION</td>
</tr>
<tr>
<td colspan="2">#DESCRIPTION</td>
</tr>
<tr>
<td colspan="2">
{if #IS_CUMULATIVE}
<span class="label label-success">
{intl l="May be cumulative"}
</span>
{else}
<span class="label label-important">
{intl l="Can't be cumulative"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if #IS_REMOVING_POSTAGE}
<span class="label label-important">
{intl l="Will remove postage"}
</span>
{else}
<span class="label label-success">
{intl l="Won't remove postage"}
</span>
{/if}
</td>
</tr>
<tr>
<td>{intl l='Amount'}</td>
<td>#AMOUNT</td>
</tr>
<tr>
<td>{intl l='Application field'}</td>
<td>
<ul class="list-unstyled">
{foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach}
{if !$smarty.foreach.rulesForeach.first}
<li><span class="label label-info">{intl l='And'}</span></li>
{/if}
<li>{$rule nofilter}</li>
{/foreach}
</ul>
</td>
</tr>
<tr>
<td>{intl l='Actions'}</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="icon-edit icon-white"></span> {intl l='Edit'}</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> {intl l='Enabled'}</a>
</td>
</tr>
</tbody>
</table>
{/loop}
</div>
</section>
</section> <!-- #wrapper -->
{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{/block}

View File

@@ -0,0 +1,161 @@
{extends file="admin-layout.tpl"}
{block name="check-permissions"}admin.coupon.update{/block}
{block name="page-title"}{intl l='Update coupon'}{/block}
{block name="main-content"}
<section id="wrapper" class="container">
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
</ul>
</nav>
<div class="page-header">
<h1>Coupons : <small>Update a coupon</small></h1>
</div>
{form name="thelia.admin.coupon.creation"}
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form}
{/form}
</section> <!-- #wrapper -->
{/block}
{include file='includes/confirmation-modal.html'}
{block name="javascript-initialization"}
{javascripts file='assets/bootstrap-datepicker/js/bootstrap-datepicker.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/json2.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function($){
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
// Init Rules
var initRule = function() {
var rules = [];
{foreach from=$rulesObject key=k item=rule}
var rule = {};
rule['serviceId'] = '{$rule.serviceId nofilter}';
rule['operators'] = {};
rule['values'] = {};
{foreach from=$rule.validators.setOperators key=input item=operator}
rule['operators']['{$input nofilter}'] = '{$operator nofilter}';
rule['values']['{$input nofilter}'] = '{$rule.validators.setValues[$input] nofilter}';
{/foreach}
rules.push(rule);
{/foreach}
return rules;
}
// Save Rules AJAX
var saveRuleAjax = function() {
var $url = '{$urlAjaxUpdateRules}';
console.log('save');
console.log('{$urlAjaxUpdateRules}');
console.log(rules);
console.log(JSON.stringify(rules));
$.ajax({
type: "POST",
url: $url,
{*data: {literal}{{/literal}rules:rules{literal}}{/literal},*}
data: {literal}{{/literal}rules:JSON.stringify(rules){literal}}{/literal},
statusCode: {
404: function() {
$('#constraint-add-operators-values').html(
'{intl l='Please retry'}'
);
}
}
}).done(function(data) {
$('#constraint-list').html(data);
$('#constraint-add-operators-values').html('');
});
}
// Remove 1 Rule then Save Rules AJAX
var removeRuleAjax = function($id) {
rules.slice($id, 1);
saveRuleAjax();
}
// Add 1 Rule then Save Rules AJAX
var addRuleAjax = function() {
rules.push(ruleToSave);
saveRuleAjax();
}
var rules = initRule();
console.log(rules);
// Save rules on click
var onClickSaveRule = function() {
$('#constraint-save-btn').on('click', function (e) {
addRuleAjax();
});
}
onClickSaveRule();
// Remove rule on click
var onClickDeleteRule = function() {
$('#constraint-delete-btn').on('click', function (e) {
// removeRuleAjax();
});
}
onClickDeleteRule();
// Reload effect inputs when changing effect
var onEffectChange = function() {
$('#effect').on('change', function (e) {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
});
}
onEffectChange();
// Reload rule inputs when changing effect
var onRuleChange = function() {
$('#category-rule').on('change', function (e) {
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
var url = "{$urlAjaxGetRuleInput}";
url = url.replace('ruleId', $(this).val())
$.ajax({
url: url,
statusCode: {
404: function() {
$('#constraint-add-operators-values').html(
'{intl l='Please select another rule'}'
);
}
}
}).done(function(data) {
$('#constraint-add-operators-values').html(data);
});
});
}
onRuleChange();
});
</script>
{/block}

View File

@@ -0,0 +1,294 @@
{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"}
{include file='includes/notifications.html' message=$general_error}
<form action="{$formAction}" {form_enctype form=$form} method="POST" >
<section class="row">
<div class="col-md-12 general-block-decorator">
{form_hidden_fields form=$form}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{if $value}{$value}{else}{$edit_language_locale}{/if}" />
{/form_field}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/coupon/read/{id}'}" />
{/form_field}
<div class="span4">
<div class="control-group">
<div class="col-md-4">
<div class="form-group">
<label for="code">{intl l='Code :'}</label>
{form_field form=$form field='code'}
<input id="code" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='code'}">
{if $error}{$message}{/if}
{/form_field}
</div>
<div class="form-group">
<label for="title">{intl l='Title :'}</label>
{form_field form=$form field='title'}
<input id="title" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='title'}">
{if $error}{$message}{/if}
{/form_field}
</div>
<div class="form-group">
<label for="enabled" class="checkbox">
{form_field form=$form field='isEnabled'}
<input id="enabled" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is enabled ?'}
</label>
</div>
<div class="form-group">
<label for="available-on-special-offers" class="checkbox">
{form_field form=$form field='isAvailableOnSpecialOffers'}
<input id="available-on-special-offers" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is available on special offers ?'}
</label>
</div>
<div class="form-group">
<label for="cumulative" class="checkbox">
{form_field form=$form field='isCumulative'}
<input id="cumulative" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is cumulative ?'}
</label>
</div>
<div class="form-group">
<label for="renoving-postage" class="checkbox">
{form_field form=$form field='isRemovingPostage'}
<input id="renoving-postage" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is removing postage ?'}
</label>
</div>
<div class="form-group">
<label for="expiration-date">{intl l='Expiration date :'}</label>
<div class="input-append date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">
{form_field form=$form field='expirationDate'}
<input type="text" id="expiration-date" name="{$name}" value="{if $defaultDate}{$defaultDate}{else}{$value}{/if}">
{if $error}{$message}{/if}
{/form_field}
<span class="add-on"><span class="icon-th"></span></span>
</div>
</div>
<div class="form-group">
<label for="max-usage">{intl l='Max usage :'}</label>
<label for="is-unlimited" class="checkbox">
<input id="is-unlimited" type="checkbox" name="is-unlimited" checked >
{intl l='Is unlimited ?'}
</label>
{form_field form=$form field='maxUsage'}
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='max usage'}">
{if $error}{$message}{/if}
{/form_field}
</div>
</div>
<div class="col-md-8">
<div class="well clearfix">
<div class="col-md-6">
<div class="form-group">
<label for="effect">{intl l='Effect :'}</label>
{form_field form=$form field='effect'}
<select name="{$name}" value="{$value}" id="effect" class="col-md-12 form-control">
{foreach from=$availableCoupons item=availableCoupon}
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}">{$availableCoupon.name}</option>
{/foreach}
</select>
{if $error}{$message}{/if}
{/form_field}
<span id="effectToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="amount">{intl l='Amount :'}</label>
{form_field form=$form field='amount'}
<input id="amount" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='14.50'}">
{if $error}{$message}{/if}
{/form_field}
</div>
<div class="form-group">
<label for="category">Category :</label>
{*form_field form=$form field='category'*}
<select name="{$name}" value="{$value}" id="category" class="form-control">
<option value="1">Category 1</option>
<option value="1">Category 2</option>
<option value="1">Category 3</option>
</select>
{*if $error}{$message}{/if}*}
{*/form_field*}
</div>
</div>
</div>
<div class="form-group">
<label for="short-description">{intl l='Short description :'}</label>
{form_field form=$form field='shortDescription'}
<textarea id="short-description" name="{$name}" placeholder="{intl l='short description'}" class="span12" rows="5">{$value nofilter}</textarea>
{if $error}{$message}{/if}
{/form_field}
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-12">
<div class="form-group">
<label for="description">{intl l='Long description :'}</label>
{form_field form=$form field='description'}
<textarea id="description" name="{$name}" placeholder="{intl l='long description'}" class="form-control wysiwyg" rows="10">{$value nofilter}</textarea>
{if $error}{$message}{/if}
{/form_field}
</div>
<button type="submit" class="btn btn-default btn-primary">{intl l='Save'}</button>
</div>
</div>
</section>
<section class="row">
<div class="col-md-12 general-block-decorator">
<table class="table table-striped">
<caption class="clearfix">
{intl l='Rules'}
</caption>
<thead>
<tr>
<th>{intl l='Conditions'}</th>
<th>{intl l='Actions'}</th>
</tr>
</thead>
<tbody id="constraint-list">
{include file='coupon/rules.html' rules=$rulesObject}
{*{foreach from=$rulesObject item=rule name=rulesForeach}*}
{*<tr>*}
{*<td>*}
{*{if !$smarty.foreach.rulesForeach.first}*}
{*<span class="label label-info">{intl l='And'}</span>*}
{*{/if}*}
{*{$rule.tooltip nofilter}*}
{*</td>*}
{*<td>*}
{*<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}</a>*}
{*<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#delete"><span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}</a>*}
{*</td>*}
{*</tr>*}
{*{/foreach}*}
</tbody>
</table>
</div>
</section>
<section class="row">
<div class="col-md-12 general-block-decorator clearfix">
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
<div id="rule-add-organizer" class="form-group col-md-2">
<label for="type">{intl l='Condition type :'}</label>
<label class="radio">
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
</label>
<label class="radio">
<input type="radio" name="type" value="2"> {intl l='Or'}
</label>
</div>
<div id="rule-add-type" class="form-group col-md-4">
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
<select name="categoryRule" id="category-rule" class="form-control">
{foreach from=$availableRules item=availableRule}
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
{/foreach}
</select>
</div>
<div id="constraint-add-operators-values" class="form-group col-md-6">
{*<label for="operator">{intl l='Operator :'}</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
{*<select name="operator" id="operator" class="form-control">*}
{*<option value="1">is superior to</option>*}
{*<option value="2">equals to</option>*}
{*<option value="3">is inferior to</option>*}
{*<option value="4">is inferior or equals to</option>*}
{*<option value="5">is superior or equals to</option>*}
{*</select>*}
{*</div>*}
{*<div class="input-group col-lg-6">*}
{*<input type="text" name="value" class="form-control">*}
{*<span class="input-group-addon">&euro;</span>*}
{*</div>*}
{*</div>*}
{**}
{*<label for="operator">Operator :</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
{*<select name="operator" id="operator" class="form-control">*}
{*<option value="1">is superior to</option>*}
{*<option value="2">equals to</option>*}
{*<option value="3">is inferior to</option>*}
{*<option value="4">is inferior or equals to</option>*}
{*<option value="5">is superior or equals to</option>*}
{*</select>*}
{*</div>*}
{*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
{*<input type="text" name="value" class="form-control">*}
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
{*</div>*}
{*</div>*}
{*<label for="operator">Operator :</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
{*<select name="operator" id="operator" class="form-control">*}
{*<option value="1">is superior to</option>*}
{*<option value="2">equals to</option>*}
{*<option value="3">is inferior to</option>*}
{*<option value="4">is inferior or equals to</option>*}
{*<option value="5">is superior or equals to</option>*}
{*</select>*}
{*</div>*}
{*<div class="col-lg-6">*}
{*<input type="text" name="value" class="form-control">*}
{*</div>*}
{*</div>*}
{*<div class="row">*}
{*<div class="col-lg-12">*}
{*<table class="table table-bordered">*}
{*<tr>*}
{*<td id="minibrowser-breadcrumb"></td>*}
{*</tr>*}
{*<tr>*}
{*<th><span class="icon-th-list"></span> Categories list</th>*}
{*</tr>*}
{*<tr>*}
{*<td id="minibrowser-categories"></td>*}
{*</tr>*}
{*</table>*}
{*</div>*}
{*</div>*}
</div>
</div>
</section>
</form>

View File

@@ -0,0 +1,102 @@
{*{$inputs.inputs|var_dump}*}
{foreach from=$inputs.inputs key=name item=input}
<label for="operator">{$input.title}</label>
<div class="row">
<div class="col-lg-6">
<select class="form-control" id="{$name}-operator" name="{$name}[operator]">
{foreach from=$input.availableOperators key=k item=availableOperator}
<option value="{$k}">{$availableOperator}</option>
{/foreach}
</select>
</div>
<div class="input-group col-lg-6">
{if $input.type == 'select'}
<select class="{$input.class}" id="{$name}-value" name="{$name}[value]">
{foreach from=$input.availableValues key=code item=availableValue}
<option value="{$code}">{$availableValue}</option>
{/foreach}
</select>
{else}
<input type="{$input.type}" class="{$input.class}" id="{$name}-value" name="{$name}[value]">
{*<span class="input-group-addon"></span>*}
{/if}
</div>
</div>
{/foreach}
{*<label for="operator">Operator :</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
{*<select class="form-control" id="operator" name="operator">*}
{*<option value="1">is superior to</option>*}
{*<option value="2">equals to</option>*}
{*<option value="3">is inferior to</option>*}
{*<option value="4">is inferior or equals to</option>*}
{*<option value="5">is superior or equals to</option>*}
{*</select>*}
{*</div>*}
{*<div data-date-format="dd/mm/yyyy" data-date="12/02/2012" class="input-group col-lg-6 date">*}
{*<input type="text" class="form-control" name="value">*}
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
{*</div>*}
{*</div>*}
{*<label for="operator">Operator :</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
{*<select class="form-control" id="operator" name="operator">*}
{*<option value="1">is superior to</option>*}
{*<option value="2">equals to</option>*}
{*<option value="3">is inferior to</option>*}
{*<option value="4">is inferior or equals to</option>*}
{*<option value="5">is superior or equals to</option>*}
{*</select>*}
{*</div>*}
{*<div class="col-lg-6">*}
{*<input type="text" class="form-control" name="value">*}
{*</div>*}
{*</div>*}
{*<div class="row">*}
{*<div class="col-lg-12">*}
{*<table class="table table-bordered">*}
{*<tbody><tr>*}
{*<td id="minibrowser-breadcrumb"><div><span> &gt; </span><a href="#">Racine</a></div></td>*}
{*</tr>*}
{*<tr>*}
{*<th><span class="icon-th-list"></span> Categories list</th>*}
{*</tr>*}
{*<tr>*}
{*<td id="minibrowser-categories"><div><p><a href="#">Boyaux</a></p><p><a href="#">Epices / condiments</a></p><p><a href="#">Emballage</a></p><p><a href="#">Petits matériels</a></p><p><a href="#">Materiel de cuisine</a></p><p><a href="#">Bacs</a></p><p><a href="#">Hygiène &amp; entretien</a></p><p><a href="#">Art de la table</a></p><p><a href="#">Matériels</a></p></div></td>*}
{*</tr>*}
{*</tbody></table>*}
{*</div>*}
{*</div>*}
<script>
var ruleToSave = {};
ruleToSave['serviceId'] = '{$ruleId}';
ruleToSave['operators'] = {};
ruleToSave['values'] = {};
{foreach from=$inputs.inputs key=name item=input}
ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
{/foreach}
// Update ruleToSave Array ready to be saved
var onInputsChange = function() {literal}{{/literal}
{foreach from=$inputs.inputs key=name item=input}
$('#{$name}-operator').change(function (e) {
var $this = $(this);
ruleToSave['operators']['{$name nofilter}'] = $this.val();
console.log('#{$name}-operator changed ' + $this.val());
console.log(ruleToSave);
});
$('#{$name}-value').change(function (e) {
var $this = $(this);
ruleToSave['values']['{$name nofilter}'] = $this.val();
console.log('#{$name}-value changed ' + $this.val());
console.log(ruleToSave);
});
{/foreach}
{literal}}{/literal}
onInputsChange();
</script>

View File

@@ -0,0 +1,18 @@
{foreach from=$rules item=rule name=rulesForeach}
<tr>
<td>
{if !$smarty.foreach.rulesForeach.first}
<span class="label label-info">{intl l='And'}</span>
{/if}
{$rule nofilter}
</td>
<td>
<a class="btn btn-default btn-primary btn-medium" href="{$urlEdit}">
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
</a>
<a data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium" href="{$urlDelete}">
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
</a>
</td>
</tr>
{/foreach}

View File

@@ -0,0 +1,139 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Customer'}{/block}
{block name="check-permissions"}admin.customer.view{/block}
{block name="main-content"}
{assign var=customer_page value={$smarty.get.page|default:1}}
<div class="catalog">
<div id="wrapper" class="container">
{module_include location='customer_top'}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<table class="table table-striped table-condensed" id="customer_list">
<caption>
{intl l="Customers list"}
{module_include location='customer_list_caption'}
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.customers.create"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new Customer'}" href="#add_customer_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
{ifloop rel="customer_list"}
<thead>
<tr>
<th class="object-title">
{intl l="customer ref"}
</th>
<th class="object-title">
{intl l="company"}
</th>
{module_include location='category_list_header'}
<th>
{intl l="firstname & lastname"}
</th>
<th>
{intl l="last order"}
</th>
<th>{intl l='order amount'}</th>
<th>{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="customer_list" type="customer" current="false" visible="*" last_order="1" backend_context="1" page={$customer_page} limit={$display_customer}}
<tr>
<td>{#REF}</td>
<td>
{#COMPANY}
</td>
<td class="object-title">
{#FIRSTNAME} {#LASTNAME}
</td>
{module_include location='customer_list_row'}
<td>
{format_date date=$LASTORDER_DATE}
</td>
<td>
{format_number number=$LASTORDER_AMOUNT}
</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.customer.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this customer'}" href="{url path="/admin/customer/update/{$ID}" }"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_send_mail" roles="ADMIN" permissions="admin.customer.sendMail"}
<a class="btn btn-default btn-xs" title="{intl l="Send a mail to this customer"}" href="mailto:{#EMAIL}"><span class="glyphicon glyphicon-envelope"></span></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.customer.delete"}
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_customer_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
{/ifloop}
</table>
</div>
</div>
</div>
{module_include location='customer_bottom'}
<div class="row">
<div class="col-md-12 text-center">
<ul class="pagination pagination-centered">
{if #customer_page != 1}
<li><a href="{url path="/admin/customers" page="1"}">&laquo;</a></li>
{else}
<li class="disabled"><a href="#">&laquo;</a></li>
{/if}
{pageloop rel="customer_list"}
{if #PAGE != #CURRENT}
<li><a href="{url path="/admin/customers" page="#PAGE"}">#PAGE</a></li>
{else}
<li class="active"><a href="#">#PAGE</a></li>
{/if}
{if #PAGE == #LAST && #LAST != #CURRENT}
<li><a href="{url path="/admin/customers" page="#PAGE"}">&raquo;</a></li>
{else}
<li class="disabled"><a href="#">&raquo;</a></li>
{/if}
{/pageloop}
</ul>
</div>
</div>
</div>
</div>
{/block}

View File

@@ -0,0 +1,36 @@
{*
Params
- id : aside element id (default delete)
- title : modal title (default Confirmation)
- message : modal message (default Do you really want to delete this element ?)
*}
{block name="confirmation-modal"}
<aside id="{if $id}{$id}{else}delete{/if}" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3>
{if $title}
{$title}
{else}
{intl l='Confirmation'}
{/if}
</h3>
</div>
<div class="modal-body">
<p>
{if $message}
{$message}
{else}
{intl l='Do you really want to delete this element ?'}
{/if}
</p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">{intl l='Cancel'}</button>
<a href="#" class="btn btn-default btn-success" data-confirm="confirm">{intl l='Confirm'}</a>
</div>
</div>
</div>
</aside> <!-- #delete / Delete confirmation -->
{/block}

View File

@@ -0,0 +1,5 @@
{* Breadcrumb for coupon browsing and editing *}
<li><a href="{url path='admin/home'}">Home</a></li>
<li><a href="{url path='admin/coupon'}">Coupon</a></li>
<li><a href="{url path="admin/coupon/browse/$ID"}">Browse</a></li>

View File

@@ -0,0 +1,11 @@
{*
Params
- type : notification type (default alert)
- message : modal message
*}
{if $message}
<div class="{if $type}$type{else}alert alert-info{/if}">
<span class="icon-question-sign"></span>
{$message}
</div>
{/if}