1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-18 23:42:25 +02:00

Added support for creating payments through the API

This commit is contained in:
Hillel Coren 2015-07-05 11:01:16 +03:00
parent 6455bf757b
commit 39ba8d1287
7 changed files with 337 additions and 225 deletions

View File

@ -1,8 +1,10 @@
<?php namespace App\Http\Controllers;
use Input;
use Utils;
use Response;
use App\Models\Payment;
use App\Models\Invoice;
use App\Ninja\Repositories\PaymentRepository;
class PaymentApiController extends Controller
@ -16,7 +18,10 @@ class PaymentApiController extends Controller
public function index()
{
$payments = Payment::scope()->with('client', 'contact', 'invitation', 'user', 'invoice')->orderBy('created_at', 'desc')->get();
$payments = Payment::scope()
->with('client', 'contact', 'invitation', 'user', 'invoice')
->orderBy('created_at', 'desc')
->get();
$payments = Utils::remapPublicIds($payments);
$response = json_encode($payments, JSON_PRETTY_PRINT);
@ -25,15 +30,38 @@ class PaymentApiController extends Controller
return Response::make($response, 200, $headers);
}
/*
public function store()
{
$data = Input::all();
$invoice = $this->invoiceRepo->save(false, $data, false);
$response = json_encode($invoice, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
*/
public function store()
{
$data = Input::all();
$error = false;
if (isset($data['invoice_id'])) {
$invoice = Invoice::scope($data['invoice_id'])->with('client')->first();
if ($invoice) {
$data['invoice'] = $invoice->public_id;
$data['client'] = $invoice->client->public_id;
} else {
$error = trans('validation.not_in', ['attribute' => 'invoice_id']);
}
} else {
$error = trans('validation.not_in', ['attribute' => 'invoice_id']);
}
if (!isset($data['transaction_reference'])) {
$data['transaction_reference'] = '';
}
if (!$error) {
$payment = $this->paymentRepo->save(false, $data);
$payment = Payment::scope($payment->public_id)->with('client', 'contact', 'user', 'invoice')->first();
$payment = Utils::remapPublicIds([$payment]);
}
$response = json_encode($error ?: $payment, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
}

View File

@ -108,7 +108,14 @@ class PaymentRepository
$payment->payment_type_id = $paymentTypeId;
}
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
if (isset($input['payment_date_sql'])) {
$payment->payment_date = $input['payment_date_sql'];
} elseif (isset($input['payment_date'])) {
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
} else {
$payment->payment_date = date('Y-m-d');
}
$payment->transaction_reference = trim($input['transaction_reference']);
if (!$publicId) {

View File

@ -2,22 +2,22 @@
"name": "hillelcoren/invoice-ninja",
"version": "0.9.0",
"dependencies": {
"jquery": "~1.11",
"bootstrap": "~3.*",
"jquery-ui": "~1.*",
"jquery": "1.11.3",
"bootstrap": "3.3.1",
"jquery-ui": "1.11.2",
"datatables": "1.10.4",
"datatables-bootstrap3": "*",
"knockout.js": "~3.*",
"knockout-mapping": "*",
"knockout-sortable": "*",
"knockout.js": "3.1.0",
"knockout-mapping": "2.4.1",
"knockout-sortable": "0.9.3",
"font-awesome": "~4.*",
"underscore": "~1.*",
"jspdf": "*",
"bootstrap-datepicker": "~1.*",
"typeahead.js": "~0.9.3",
"accounting": "~0.*",
"spectrum": "~1.3.4",
"d3": "~3.4.11",
"underscore": "1.7.0",
"jspdf": "1.0.272",
"bootstrap-datepicker": "1.4.0",
"typeahead.js": "0.9.3",
"accounting": "0.3.2",
"spectrum": "1.3.4",
"d3": "3.4.11",
"handsontable": "*",
"pdfmake": "*",
"moment": "*"

60
public/css/built.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27152,31 +27152,13 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
}
}.call(this));
/* =========================================================
* bootstrap-datepicker.js
* Repo: https://github.com/eternicode/bootstrap-datepicker/
* Demo: http://eternicode.github.io/bootstrap-datepicker/
* Docs: http://bootstrap-datepicker.readthedocs.org/
* Forked from http://www.eyecon.ro/bootstrap-datepicker
* =========================================================
* Started by Stefan Petre; improvements by Andrew Rowls + contributors
/*!
* Datepicker for Bootstrap v1.4.0 (https://github.com/eternicode/bootstrap-datepicker)
*
* 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($, undefined){
var $window = $(window);
* Copyright 2012 Stefan Petre
* Improvements by Andrew Rowls
* Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/(function($, undefined){
function UTCDate(){
return new Date(Date.UTC.apply(Date, arguments));
@ -27185,6 +27167,13 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
var today = new Date();
return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
}
function isUTCEquals(date1, date2) {
return (
date1.getUTCFullYear() === date2.getUTCFullYear() &&
date1.getUTCMonth() === date2.getUTCMonth() &&
date1.getUTCDate() === date2.getUTCDate()
);
}
function alias(method){
return function(){
return this[method].apply(this, arguments);
@ -27238,16 +27227,16 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
// Picker object
var Datepicker = function(element, options){
this.dates = new DateArray();
this.viewDate = UTCToday();
this.focusDate = null;
this._process_options(options);
this.dates = new DateArray();
this.viewDate = this.o.defaultViewDate;
this.focusDate = null;
this.element = $(element);
this.isInline = false;
this.isInput = this.element.is('input');
this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
this.hasInput = this.component && this.element.find('input').length;
if (this.component && this.component.length === 0)
this.component = false;
@ -27270,7 +27259,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.viewMode = this.o.startView;
if (this.o.calendarWeeks)
this.picker.find('tfoot th.today, tfoot th.clear')
this.picker.find('tfoot .today, tfoot .clear')
.attr('colspan', function(i, val){
return parseInt(val) + 1;
});
@ -27280,6 +27269,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.setStartDate(this._o.startDate);
this.setEndDate(this._o.endDate);
this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
this.setDatesDisabled(this.o.datesDisabled);
this.fillDow();
this.fillMonths();
@ -27346,8 +27336,6 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
o.multidate = Number(o.multidate) || false;
if (o.multidate !== false)
o.multidate = Math.max(0, o.multidate);
else
o.multidate = 1;
}
o.multidateSeparator = String(o.multidateSeparator);
@ -27385,10 +27373,20 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
return parseInt(d, 10);
});
o.datesDisabled = o.datesDisabled||[];
if (!$.isArray(o.datesDisabled)) {
var datesDisabled = [];
datesDisabled.push(DPGlobal.parseDate(o.datesDisabled, format, o.language));
o.datesDisabled = datesDisabled;
}
o.datesDisabled = $.map(o.datesDisabled,function(d){
return DPGlobal.parseDate(d, format, o.language);
});
var plc = String(o.orientation).toLowerCase().split(/\s+/g),
_plc = o.orientation.toLowerCase();
plc = $.grep(plc, function(word){
return (/^auto|left|right|top|bottom$/).test(word);
return /^auto|left|right|top|bottom$/.test(word);
});
o.orientation = {x: 'auto', y: 'auto'};
if (!_plc || _plc === 'auto')
@ -27407,15 +27405,24 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
}
else {
_plc = $.grep(plc, function(word){
return (/^left|right$/).test(word);
return /^left|right$/.test(word);
});
o.orientation.x = _plc[0] || 'auto';
_plc = $.grep(plc, function(word){
return (/^top|bottom$/).test(word);
return /^top|bottom$/.test(word);
});
o.orientation.y = _plc[0] || 'auto';
}
if (o.defaultViewDate) {
var year = o.defaultViewDate.year || new Date().getFullYear();
var month = o.defaultViewDate.month || 0;
var day = o.defaultViewDate.day || 1;
o.defaultViewDate = UTCDate(year, month, day);
} else {
o.defaultViewDate = UTCToday();
}
o.showOnFocus = o.showOnFocus !== undefined ? o.showOnFocus : true;
},
_events: [],
_secondaryEvents: [],
@ -27448,34 +27455,32 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
}
},
_buildEvents: function(){
if (this.isInput){ // single input
this._events = [
[this.element, {
focus: $.proxy(this.show, this),
keyup: $.proxy(function(e){
if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
this.update();
}, this),
keydown: $.proxy(this.keydown, this)
}]
];
}
else if (this.component && this.hasInput){ // component: input + button
this._events = [
// For components that are not readonly, allow keyboard nav
[this.element.find('input'), {
focus: $.proxy(this.show, this),
keyup: $.proxy(function(e){
if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
this.update();
}, this),
keydown: $.proxy(this.keydown, this)
}],
[this.component, {
click: $.proxy(this.show, this)
}]
];
}
var events = {
keyup: $.proxy(function(e){
if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
this.update();
}, this),
keydown: $.proxy(this.keydown, this)
};
if (this.o.showOnFocus === true) {
events.focus = $.proxy(this.show, this);
}
if (this.isInput) { // single input
this._events = [
[this.element, events]
];
}
else if (this.component && this.hasInput) { // component: input + button
this._events = [
// For components that are not readonly, allow keyboard nav
[this.element.find('input'), events],
[this.component, {
click: $.proxy(this.show, this)
}]
];
}
else if (this.element.is('div')){ // inline datepicker
this.isInline = true;
}
@ -27562,19 +27567,25 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
},
show: function(){
if (this.element.attr('readonly') && this.o.enableOnReadonly === false)
return;
if (!this.isInline)
this.picker.appendTo('body');
this.picker.show();
this.picker.appendTo(this.o.container);
this.place();
this.picker.show();
this._attachSecondaryEvents();
this._trigger('show');
if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document) && this.o.disableTouchKeyboard) {
$(this.element).blur();
}
return this;
},
hide: function(){
if (this.isInline)
return;
return this;
if (!this.picker.is(':visible'))
return;
return this;
this.focusDate = null;
this.picker.hide().detach();
this._detachSecondaryEvents();
@ -27590,6 +27601,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
)
this.setValue();
this._trigger('hide');
return this;
},
remove: function(){
@ -27601,6 +27613,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
if (!this.isInput){
delete this.element.data().date;
}
return this;
},
_utc_to_local: function(utc){
@ -27631,14 +27644,39 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
},
getUTCDate: function(){
return new Date(this.dates.get(-1));
var selected_date = this.dates.get(-1);
if (typeof selected_date !== 'undefined') {
return new Date(selected_date);
} else {
return null;
}
},
clearDates: function(){
var element;
if (this.isInput) {
element = this.element;
} else if (this.component) {
element = this.element.find('input');
}
if (element) {
element.val('').change();
}
this.update();
this._trigger('changeDate');
if (this.o.autoclose) {
this.hide();
}
},
setDates: function(){
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
this.update.apply(this, args);
this._trigger('changeDate');
this.setValue();
return this;
},
setUTCDates: function(){
@ -27646,6 +27684,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.update.apply(this, $.map(args, this._utc_to_local));
this._trigger('changeDate');
this.setValue();
return this;
},
setDate: alias('setDates'),
@ -27661,6 +27700,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
else {
this.element.val(formatted).change();
}
return this;
},
getFormattedDate: function(format){
@ -27677,41 +27717,51 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this._process_options({startDate: startDate});
this.update();
this.updateNavArrows();
return this;
},
setEndDate: function(endDate){
this._process_options({endDate: endDate});
this.update();
this.updateNavArrows();
return this;
},
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
this.update();
this.updateNavArrows();
return this;
},
setDatesDisabled: function(datesDisabled){
this._process_options({datesDisabled: datesDisabled});
this.update();
this.updateNavArrows();
},
place: function(){
if (this.isInline)
return;
return this;
var calendarWidth = this.picker.outerWidth(),
calendarHeight = this.picker.outerHeight(),
visualPadding = 10,
windowWidth = $window.width(),
windowHeight = $window.height(),
scrollTop = $window.scrollTop();
windowWidth = $(this.o.container).width(),
windowHeight = $(this.o.container).height(),
scrollTop = $(this.o.container).scrollTop(),
appendOffset = $(this.o.container).offset();
var parentsZindex = [];
this.element.parents().each(function() {
this.element.parents().each(function(){
var itemZIndex = $(this).css('z-index');
if ( itemZIndex !== 'auto' && itemZIndex !== 0 ) parentsZindex.push( parseInt( itemZIndex ) );
if (itemZIndex !== 'auto' && itemZIndex !== 0) parentsZindex.push(parseInt(itemZIndex));
});
var zIndex = Math.max.apply( Math, parentsZindex ) + 10;
var zIndex = Math.max.apply(Math, parentsZindex) + 10;
var offset = this.component ? this.component.parent().offset() : this.element.offset();
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
var left = offset.left,
top = offset.top;
var left = offset.left - appendOffset.left,
top = offset.top - appendOffset.top;
this.picker.removeClass(
'datepicker-orient-top datepicker-orient-bottom '+
@ -27726,12 +27776,18 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
// auto x orientation is best-placement: if it crosses a window
// edge, fudge it sideways
else {
// Default to left
this.picker.addClass('datepicker-orient-left');
if (offset.left < 0)
if (offset.left < 0) {
// component is outside the window on the left side. Move it into visible range
this.picker.addClass('datepicker-orient-left');
left -= offset.left - visualPadding;
else if (offset.left + calendarWidth > windowWidth)
left = windowWidth - calendarWidth - visualPadding;
} else if (left + calendarWidth > windowWidth) {
// the calendar passes the widow right edge. Align it to component right side
this.picker.addClass('datepicker-orient-right');
left = offset.left + width - calendarWidth;
} else {
// Default to left
this.picker.addClass('datepicker-orient-left');
}
}
// auto y orientation is best-situation: top or bottom, no fudging,
@ -27739,8 +27795,8 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
var yorient = this.o.orientation.y,
top_overflow, bottom_overflow;
if (yorient === 'auto'){
top_overflow = -scrollTop + offset.top - calendarHeight;
bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
top_overflow = -scrollTop + top - calendarHeight;
bottom_overflow = scrollTop + windowHeight - (top + height + calendarHeight);
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
yorient = 'top';
else
@ -27752,17 +27808,27 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
else
top -= calendarHeight + parseInt(this.picker.css('padding-top'));
this.picker.css({
top: top,
left: left,
zIndex: zIndex
});
if (this.o.rtl) {
var right = windowWidth - (left + width);
this.picker.css({
top: top,
right: right,
zIndex: zIndex
});
} else {
this.picker.css({
top: top,
left: left,
zIndex: zIndex
});
}
return this;
},
_allow_update: true,
update: function(){
if (!this._allow_update)
return;
return this;
var oldDates = this.dates.copy(),
dates = [],
@ -27818,15 +27884,19 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this._trigger('clearDate');
this.fill();
return this;
},
fillDow: function(){
var dowCnt = this.o.weekStart,
html = '<tr>';
if (this.o.calendarWeeks){
var cell = '<th class="cw">&nbsp;</th>';
this.picker.find('.datepicker-days thead tr:first-child .datepicker-switch')
.attr('colspan', function(i, val){
return parseInt(val) + 1;
});
var cell = '<th class="cw">&#160;</th>';
html += cell;
this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
}
while (dowCnt < this.o.weekStart + 7){
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
@ -27880,6 +27950,12 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
cls.push('disabled');
}
if (this.o.datesDisabled.length > 0 &&
$.grep(this.o.datesDisabled, function(d){
return isUTCEquals(date, d); }).length > 0) {
cls.push('disabled', 'disabled-date');
}
if (this.range){
if (date > this.range[0] && date < this.range[this.range.length-1]){
cls.push('range');
@ -27902,13 +27978,14 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
todaytxt = dates[this.o.language].today || dates['en'].today || '',
cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
tooltip;
if (isNaN(year) || isNaN(month)) return;
this.picker.find('.datepicker-days thead th.datepicker-switch')
if (isNaN(year) || isNaN(month))
return;
this.picker.find('.datepicker-days thead .datepicker-switch')
.text(dates[this.o.language].months[month]+' '+year);
this.picker.find('tfoot th.today')
this.picker.find('tfoot .today')
.text(todaytxt)
.toggle(this.o.todayBtn !== false);
this.picker.find('tfoot th.clear')
this.picker.find('tfoot .clear')
.text(cleartxt)
.toggle(this.o.clearBtn !== false);
this.updateNavArrows();
@ -27991,6 +28068,18 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
months.slice(endMonth+1).addClass('disabled');
}
if (this.o.beforeShowMonth !== $.noop){
var that = this;
$.each(months, function(i, month){
if (!$(month).hasClass('disabled')) {
var moDate = new Date(year, i, 1);
var before = that.o.beforeShowMonth(moDate);
if (before === false)
$(month).addClass('disabled');
}
});
}
html = '';
year = parseInt(year/10, 10) * 10;
var yearCont = this.picker.find('.datepicker-years')
@ -28013,7 +28102,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
classes.push('active');
if (year < startYear || year > endYear)
classes.push('disabled');
html += '<span class="' + classes.join(' ') + '">'+year+'</span>';
html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
year += 1;
}
yearCont.html(html);
@ -28096,24 +28185,14 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this._setDate(date, which);
break;
case 'clear':
var element;
if (this.isInput)
element = this.element;
else if (this.component)
element = this.element.find('input');
if (element)
element.val("").change();
this.update();
this._trigger('changeDate');
if (this.o.autoclose)
this.hide();
this.clearDates();
break;
}
break;
case 'span':
if (!target.is('.disabled')){
if (!target.hasClass('disabled')){
this.viewDate.setUTCDate(1);
if (target.is('.month')){
if (target.hasClass('month')){
day = 1;
month = target.parent().find('span').index(target);
year = this.viewDate.getUTCFullYear();
@ -28138,11 +28217,11 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
}
break;
case 'td':
if (target.is('.day') && !target.is('.disabled')){
if (target.hasClass('day') && !target.hasClass('disabled')){
day = parseInt(target.text(), 10)||1;
year = this.viewDate.getUTCFullYear();
month = this.viewDate.getUTCMonth();
if (target.is('.old')){
if (target.hasClass('old')){
if (month === 0){
month = 11;
year -= 1;
@ -28151,7 +28230,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
month -= 1;
}
}
else if (target.is('.new')){
else if (target.hasClass('new')){
if (month === 11){
month = 0;
year += 1;
@ -28176,15 +28255,19 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
if (!date){
this.dates.clear();
}
if (this.o.multidate === 1 && ix === 0){
// single datepicker, don't remove selected date
}
else if (ix !== -1){
this.dates.remove(ix);
if (ix !== -1){
if (this.o.multidate === true || this.o.multidate > 1 || this.o.toggleActive){
this.dates.remove(ix);
}
} else if (this.o.multidate === false) {
this.dates.clear();
this.dates.push(date);
}
else {
this.dates.push(date);
}
if (typeof this.o.multidate === 'number')
while (this.dates.length > this.o.multidate)
this.dates.remove(0);
@ -28198,7 +28281,9 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.fill();
this.setValue();
this._trigger('changeDate');
if (!which || which !== 'view') {
this._trigger('changeDate');
}
var element;
if (this.isInput){
element = this.element;
@ -28273,7 +28358,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
},
keydown: function(e){
if (this.picker.is(':not(:visible)')){
if (!this.picker.is(':visible')){
if (e.keyCode === 27) // allow escape to hide and re-show picker
this.show();
return;
@ -28313,7 +28398,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
newViewDate = new Date(focusDate);
newViewDate.setUTCDate(focusDate.getUTCDate() + dir);
}
if (this.dateWithinRange(newDate)){
if (this.dateWithinRange(newViewDate)){
this.focusDate = this.viewDate = newViewDate;
this.setValue();
this.fill();
@ -28341,7 +28426,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
newViewDate = new Date(focusDate);
newViewDate.setUTCDate(focusDate.getUTCDate() + dir * 7);
}
if (this.dateWithinRange(newDate)){
if (this.dateWithinRange(newViewDate)){
this.focusDate = this.viewDate = newViewDate;
this.setValue();
this.fill();
@ -28364,6 +28449,11 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.fill();
if (this.picker.is(':visible')){
e.preventDefault();
if (typeof e.stopPropagation === 'function') {
e.stopPropagation(); // All modern browsers, IE9+
} else {
e.cancelBubble = true; // IE6,7,8 ignore "stopPropagation"
}
if (this.o.autoclose)
this.hide();
}
@ -28398,9 +28488,9 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
}
this.picker
.find('>div')
.children('div')
.hide()
.filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName)
.filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
.css('display', 'block');
this.updateNavArrows();
}
@ -28413,8 +28503,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
});
delete options.inputs;
$(this.inputs)
.datepicker(options)
datepickerPlugin.call($(this.inputs), options)
.bind('changeDate', $.proxy(this.dateUpdated, this));
this.pickers = $.map(this.inputs, function(i){
@ -28448,6 +28537,8 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
var dp = $(e.target).data('datepicker'),
new_date = dp.getUTCDate(),
i = $.inArray(e.target, this.inputs),
j = i - 1,
k = i + 1,
l = this.inputs.length;
if (i === -1)
return;
@ -28457,16 +28548,16 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
p.setUTCDate(new_date);
});
if (new_date < this.dates[i]){
if (new_date < this.dates[j]){
// Date being moved earlier/left
while (i >= 0 && new_date < this.dates[i]){
this.pickers[i--].setUTCDate(new_date);
while (j >= 0 && new_date < this.dates[j]){
this.pickers[j--].setUTCDate(new_date);
}
}
else if (new_date > this.dates[i]){
else if (new_date > this.dates[k]){
// Date being moved later/right
while (i < l && new_date > this.dates[i]){
this.pickers[i++].setUTCDate(new_date);
while (k < l && new_date > this.dates[k]){
this.pickers[k++].setUTCDate(new_date);
}
}
this.updateDates();
@ -28515,7 +28606,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
}
var old = $.fn.datepicker;
$.fn.datepicker = function(option){
var datepickerPlugin = function(option){
var args = Array.apply(null, arguments);
args.shift();
var internal_return;
@ -28530,7 +28621,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
locopts = opts_from_locale(xopts.language),
// Options priority: js args, data-attrs, locales, defaults
opts = $.extend({}, defaults, locopts, elopts, options);
if ($this.is('.input-daterange') || opts.inputs){
if ($this.hasClass('input-daterange') || opts.inputs){
var ropts = {
inputs: opts.inputs || $this.find('input').toArray()
};
@ -28551,13 +28642,17 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
else
return this;
};
$.fn.datepicker = datepickerPlugin;
var defaults = $.fn.datepicker.defaults = {
autoclose: false,
beforeShowDay: $.noop,
beforeShowMonth: $.noop,
calendarWeeks: false,
clearBtn: false,
toggleActive: false,
daysOfWeekDisabled: [],
datesDisabled: [],
endDate: Infinity,
forceParse: true,
format: 'mm/dd/yyyy',
@ -28572,7 +28667,10 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
startView: 0,
todayBtn: false,
todayHighlight: false,
weekStart: 0
weekStart: 0,
disableTouchKeyboard: false,
enableOnReadonly: true,
container: 'body'
};
var locale_opts = $.fn.datepicker.locale_opts = [
'format',
@ -28700,7 +28798,7 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
function match_part(){
var m = this.slice(0, parts[i].length),
p = parts[i].slice(0, m.length);
return m === p;
return m.toLowerCase() === p.toLowerCase();
}
if (parts.length === fparts.length){
var cnt;
@ -28762,9 +28860,9 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
},
headTemplate: '<thead>'+
'<tr>'+
'<th class="prev">&laquo;</th>'+
'<th class="prev">&#171;</th>'+
'<th colspan="5" class="datepicker-switch"></th>'+
'<th class="next">&raquo;</th>'+
'<th class="next">&#187;</th>'+
'</tr>'+
'</thead>',
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
@ -28812,6 +28910,9 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
return this;
};
/* DATEPICKER VERSION
* =================== */
$.fn.datepicker.version = "1.4.0";
/* DATEPICKER DATA-API
* ================== */
@ -28825,11 +28926,11 @@ d[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:d[b]=c(j,a.p
return;
e.preventDefault();
// component click requires us to explicitly show it
$this.datepicker('show');
datepickerPlugin.call($this, 'show');
}
);
$(function(){
$('[data-provide="datepicker-inline"]').datepicker();
datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
});
}(window.jQuery));

File diff suppressed because one or more lines are too long