mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Merge branch 'master' into redesign-2015
This commit is contained in:
commit
6af1c02f06
14 changed files with 351 additions and 84 deletions
|
@ -443,7 +443,7 @@ return array(
|
|||
'rsrc/js/core/behavior-device.js' => 'a205cf28',
|
||||
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
|
||||
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
|
||||
'rsrc/js/core/behavior-fancy-datepicker.js' => '510b5809',
|
||||
'rsrc/js/core/behavior-fancy-datepicker.js' => 'ea5cec5d',
|
||||
'rsrc/js/core/behavior-file-tree.js' => '88236f00',
|
||||
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
|
||||
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
|
||||
|
@ -467,7 +467,7 @@ return array(
|
|||
'rsrc/js/core/behavior-scrollbar.js' => '834a1173',
|
||||
'rsrc/js/core/behavior-search-typeahead.js' => '048330fa',
|
||||
'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6',
|
||||
'rsrc/js/core/behavior-time-typeahead.js' => '8bfbb401',
|
||||
'rsrc/js/core/behavior-time-typeahead.js' => 'f80d6bf0',
|
||||
'rsrc/js/core/behavior-toggle-class.js' => '5d7c9f33',
|
||||
'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884',
|
||||
'rsrc/js/core/behavior-tooltip.js' => '3ee3408b',
|
||||
|
@ -575,7 +575,7 @@ return array(
|
|||
'javelin-behavior-durable-column' => 'c72aa091',
|
||||
'javelin-behavior-error-log' => '6882e80a',
|
||||
'javelin-behavior-event-all-day' => '38dcf3c8',
|
||||
'javelin-behavior-fancy-datepicker' => '510b5809',
|
||||
'javelin-behavior-fancy-datepicker' => 'ea5cec5d',
|
||||
'javelin-behavior-global-drag-and-drop' => 'c8e57404',
|
||||
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
|
||||
'javelin-behavior-high-security-warning' => 'a464fe03',
|
||||
|
@ -643,7 +643,7 @@ return array(
|
|||
'javelin-behavior-slowvote-embed' => '887ad43f',
|
||||
'javelin-behavior-stripe-payment-form' => '3f5d6dbf',
|
||||
'javelin-behavior-test-payment-form' => 'fc91ab6c',
|
||||
'javelin-behavior-time-typeahead' => '8bfbb401',
|
||||
'javelin-behavior-time-typeahead' => 'f80d6bf0',
|
||||
'javelin-behavior-toggle-class' => '5d7c9f33',
|
||||
'javelin-behavior-typeahead-browse' => '635de1ec',
|
||||
'javelin-behavior-typeahead-search' => '93d0c9e3',
|
||||
|
@ -1172,13 +1172,6 @@ return array(
|
|||
'javelin-typeahead-source',
|
||||
'javelin-util',
|
||||
),
|
||||
'510b5809' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'519705ea' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
|
@ -1518,14 +1511,6 @@ return array(
|
|||
'javelin-request',
|
||||
'javelin-typeahead-source',
|
||||
),
|
||||
'8bfbb401' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
'javelin-typeahead-static-source',
|
||||
),
|
||||
'8ce821c5' => array(
|
||||
'phabricator-notification',
|
||||
'javelin-stratcom',
|
||||
|
@ -1953,6 +1938,13 @@ return array(
|
|||
'javelin-dom',
|
||||
'phabricator-draggable-list',
|
||||
),
|
||||
'ea5cec5d' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'ea681761' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-aphlict',
|
||||
|
@ -1998,6 +1990,14 @@ return array(
|
|||
'javelin-typeahead-ondemand-source',
|
||||
'javelin-util',
|
||||
),
|
||||
'f80d6bf0' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
'javelin-typeahead-static-source',
|
||||
),
|
||||
'f829edb3' => array(
|
||||
'javelin-view',
|
||||
'javelin-install',
|
||||
|
|
|
@ -191,7 +191,7 @@ final class PhabricatorCalendarEventEditController
|
|||
PhabricatorCalendarEventTransaction::TYPE_NAME)
|
||||
->setNewValue($name);
|
||||
|
||||
if ($is_parent && $this->isCreate()) {
|
||||
if ($is_recurring && $this->isCreate()) {
|
||||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarEventTransaction::TYPE_RECURRING)
|
||||
|
@ -210,7 +210,7 @@ final class PhabricatorCalendarEventEditController
|
|||
}
|
||||
}
|
||||
|
||||
if (($is_parent && $this->isCreate()) || !$is_parent) {
|
||||
if (($is_recurring && $this->isCreate()) || !$is_parent) {
|
||||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarEventTransaction::TYPE_ALL_DAY)
|
||||
|
|
|
@ -315,8 +315,14 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
|||
$user,
|
||||
$time_str);
|
||||
|
||||
$secondary_info = pht('%s, %s',
|
||||
$handles[$status->getUserPHID()]->getName(), $epoch_range);
|
||||
if (isset($handles[$status->getUserPHID()])) {
|
||||
$secondary_info = pht(
|
||||
'%s, %s',
|
||||
$handles[$status->getUserPHID()]->getName(),
|
||||
$epoch_range);
|
||||
} else {
|
||||
$secondary_info = $epoch_range;
|
||||
}
|
||||
|
||||
$content[] = phutil_tag(
|
||||
'div',
|
||||
|
|
|
@ -179,6 +179,7 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
|||
$xatoms = id(new DivinerAtomQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withNames($names)
|
||||
->withGhosts(false)
|
||||
->needExtends(true)
|
||||
->needAtoms(true)
|
||||
->needChildren($this->needChildren)
|
||||
|
|
|
@ -10,6 +10,10 @@ final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
|
|||
$atom = $this->loadDocumentByPHID($phid);
|
||||
$book = $atom->getBook();
|
||||
|
||||
if (!$atom->getIsDocumentable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$doc = $this->newDocument($phid)
|
||||
->setDocumentTitle($atom->getTitle())
|
||||
->setDocumentCreated($book->getDateCreated())
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
abstract class HarbormasterBuildStepImplementation extends Phobject {
|
||||
|
||||
private $settings;
|
||||
|
||||
public static function getImplementations() {
|
||||
return id(new PhutilSymbolLoader())
|
||||
->setAncestorClass(__CLASS__)
|
||||
|
|
|
@ -19,6 +19,7 @@ final class PhabricatorDateTimeSettingsPanel extends PhabricatorSettingsPanel {
|
|||
$username = $user->getUsername();
|
||||
|
||||
$pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
|
||||
$pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
|
||||
$pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
|
||||
$preferences = $user->loadPreferences();
|
||||
|
||||
|
@ -31,10 +32,14 @@ final class PhabricatorDateTimeSettingsPanel extends PhabricatorSettingsPanel {
|
|||
$errors[] = pht('The selected timezone is not a valid timezone.');
|
||||
}
|
||||
|
||||
$preferences->setPreference(
|
||||
$preferences
|
||||
->setPreference(
|
||||
$pref_time,
|
||||
$request->getStr($pref_time));
|
||||
$preferences->setPreference(
|
||||
$request->getStr($pref_time))
|
||||
->setPreference(
|
||||
$pref_date,
|
||||
$request->getStr($pref_date))
|
||||
->setPreference(
|
||||
$pref_week_start,
|
||||
$request->getStr($pref_week_start));
|
||||
|
||||
|
@ -69,6 +74,18 @@ final class PhabricatorDateTimeSettingsPanel extends PhabricatorSettingsPanel {
|
|||
->setCaption(
|
||||
pht('Format used when rendering a time of day.'))
|
||||
->setValue($preferences->getPreference($pref_time)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Date Format'))
|
||||
->setName($pref_date)
|
||||
->setOptions(array(
|
||||
'Y-m-d' => pht('ISO 8601 (2000-02-28)'),
|
||||
'n/j/Y' => pht('US (2/28/2000)'),
|
||||
'd-m-Y' => pht('European (28-02-2000)'),
|
||||
))
|
||||
->setCaption(
|
||||
pht('Format used when rendering a date.'))
|
||||
->setValue($preferences->getPreference($pref_date)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Week Starts On'))
|
||||
|
|
|
@ -8,6 +8,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
|
|||
const PREFERENCE_MULTIEDIT = 'multiedit';
|
||||
const PREFERENCE_TITLES = 'titles';
|
||||
const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas';
|
||||
const PREFERENCE_DATE_FORMAT = 'date-format';
|
||||
const PREFERENCE_TIME_FORMAT = 'time-format';
|
||||
const PREFERENCE_WEEK_START_DAY = 'week-start-day';
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ final class PhabricatorBot extends PhabricatorDaemon {
|
|||
private $conduit;
|
||||
private $config;
|
||||
private $pollFrequency;
|
||||
private $protocolAdapter;
|
||||
|
||||
protected function run() {
|
||||
$argv = $this->getArgv();
|
||||
|
|
|
@ -127,7 +127,29 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
}
|
||||
|
||||
private function getDateInputValue() {
|
||||
return $this->valueDate;
|
||||
$date_format = $this->getDateFormat();
|
||||
$timezone = $this->getTimezone();
|
||||
|
||||
$datetime = new DateTime($this->valueDate, $timezone);
|
||||
$date = $datetime->format($date_format);
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
private function getTimeFormat() {
|
||||
$viewer = $this->getUser();
|
||||
$preferences = $viewer->loadPreferences();
|
||||
$pref_time_format = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
|
||||
|
||||
return $preferences->getPreference($pref_time_format, 'g:i A');
|
||||
}
|
||||
|
||||
private function getDateFormat() {
|
||||
$viewer = $this->getUser();
|
||||
$preferences = $viewer->loadPreferences();
|
||||
$pref_date_format = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
|
||||
|
||||
return $preferences->getPreference($pref_date_format, 'Y-m-d');
|
||||
}
|
||||
|
||||
private function getTimeInputValue() {
|
||||
|
@ -219,6 +241,7 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
'startTimeID' => $time_id,
|
||||
'endTimeID' => $this->endDateID,
|
||||
'timeValues' => $values,
|
||||
'format' => $this->getTimeFormat(),
|
||||
));
|
||||
|
||||
|
||||
|
@ -242,7 +265,9 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
),
|
||||
$time_sel);
|
||||
|
||||
Javelin::initBehavior('fancy-datepicker', array());
|
||||
Javelin::initBehavior('fancy-datepicker', array(
|
||||
'format' => $this->getDateFormat(),
|
||||
));
|
||||
|
||||
$classes = array();
|
||||
$classes[] = 'aphront-form-date-container';
|
||||
|
@ -319,7 +344,10 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
}
|
||||
|
||||
private function getTimeTypeaheadValues() {
|
||||
$time_format = $this->getTimeFormat();
|
||||
$times = array();
|
||||
|
||||
if ($time_format == 'g:i A') {
|
||||
$am_pm_list = array('AM', 'PM');
|
||||
|
||||
foreach ($am_pm_list as $am_pm) {
|
||||
|
@ -329,10 +357,18 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
$times[] = $actual_hour.':30 '.$am_pm;
|
||||
}
|
||||
}
|
||||
} else if ($time_format == 'H:i') {
|
||||
for ($hour = 0; $hour < 24; $hour++) {
|
||||
$written_hour = ($hour > 9) ? $hour : '0'.$hour;
|
||||
$times[] = $written_hour.':00';
|
||||
$times[] = $written_hour.':30';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($times as $key => $time) {
|
||||
$times[$key] = array($key, $time);
|
||||
}
|
||||
|
||||
return $times;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
private $zone;
|
||||
private $optional;
|
||||
|
||||
|
||||
public function getValueDate() {
|
||||
return $this->valueDate;
|
||||
}
|
||||
|
@ -65,8 +66,13 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
|
||||
$value = new AphrontFormDateControlValue();
|
||||
$value->viewer = $viewer;
|
||||
$value->valueDate = $month.'/'.$day.'/'.$year;
|
||||
$value->valueTime = coalesce($time, '12:00 AM');
|
||||
list($value->valueDate, $value->valueTime) =
|
||||
$value->getFormattedDateFromParts(
|
||||
$year,
|
||||
$month,
|
||||
$day,
|
||||
coalesce($time, '12:00 AM'),
|
||||
$value);
|
||||
$value->valueEnabled = $enabled;
|
||||
|
||||
return $value;
|
||||
|
@ -75,10 +81,14 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
public static function newFromRequest(AphrontRequest $request, $key) {
|
||||
$value = new AphrontFormDateControlValue();
|
||||
$value->viewer = $request->getViewer();
|
||||
$value->valueDate = $request->getStr($key.'_d');
|
||||
$value->valueTime = $request->getStr($key.'_t');
|
||||
$value->valueEnabled = $request->getStr($key.'_e');
|
||||
|
||||
list($value->valueDate, $value->valueTime) =
|
||||
$value->getFormattedDateFromDate(
|
||||
$request->getStr($key.'_d'),
|
||||
$request->getStr($key.'_t'),
|
||||
$value);
|
||||
|
||||
$value->valueEnabled = $request->getStr($key.'_e');
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -91,10 +101,15 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
$year = $readable[0];
|
||||
$month = $readable[1];
|
||||
$day = $readable[2];
|
||||
$time = $readable[3];
|
||||
|
||||
$value->valueDate = $month.'/'.$day.'/'.$year;
|
||||
$value->valueTime = $readable[3];
|
||||
|
||||
list($value->valueDate, $value->valueTime) =
|
||||
$value->getFormattedDateFromParts(
|
||||
$year,
|
||||
$month,
|
||||
$day,
|
||||
$time,
|
||||
$value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
@ -105,8 +120,12 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
$value = new AphrontFormDateControlValue();
|
||||
$value->viewer = $viewer;
|
||||
|
||||
$value->valueDate = idx($dictionary, 'd');
|
||||
$value->valueTime = idx($dictionary, 't');
|
||||
list($value->valueDate, $value->valueTime) =
|
||||
$value->getFormattedDateFromDate(
|
||||
idx($dictionary, 'd'),
|
||||
idx($dictionary, 't'),
|
||||
$value);
|
||||
|
||||
$value->valueEnabled = idx($dictionary, 'e');
|
||||
|
||||
return $value;
|
||||
|
@ -185,6 +204,67 @@ final class AphrontFormDateControlValue extends Phobject {
|
|||
return $value;
|
||||
}
|
||||
|
||||
private function getTimeFormat() {
|
||||
$preferences = $this->viewer->loadPreferences();
|
||||
$pref_time_format = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
|
||||
|
||||
return $preferences->getPreference($pref_time_format, 'g:i A');
|
||||
}
|
||||
|
||||
private function getDateFormat() {
|
||||
$preferences = $this->viewer->loadPreferences();
|
||||
$pref_date_format = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
|
||||
|
||||
return $preferences->getPreference($pref_date_format, 'Y-m-d');
|
||||
}
|
||||
|
||||
private function getFormattedDateFromDate($date, $time, $value) {
|
||||
$original_input = $date;
|
||||
$zone = $value->getTimezone();
|
||||
$separator = $value->getFormatSeparator();
|
||||
$parts = preg_split('@[,./:-]@', $date);
|
||||
$date = implode($separator, $parts);
|
||||
$date = id(new DateTime($date, $zone));
|
||||
|
||||
if ($date) {
|
||||
$date = $date->format($value->getDateFormat());
|
||||
} else {
|
||||
$date = $original_input;
|
||||
}
|
||||
|
||||
$date = id(new DateTime("{$date} {$time}", $zone));
|
||||
|
||||
return array(
|
||||
$date->format($value->getDateFormat()),
|
||||
$date->format($value->getTimeFormat()),
|
||||
);
|
||||
}
|
||||
|
||||
private function getFormattedDateFromParts(
|
||||
$year,
|
||||
$month,
|
||||
$day,
|
||||
$time,
|
||||
$value) {
|
||||
$zone = $value->getTimezone();
|
||||
$date_time = id(new DateTime("{$year}-{$month}-{$day} {$time}", $zone));
|
||||
|
||||
return array(
|
||||
$date_time->format($value->getDateFormat()),
|
||||
$date_time->format($value->getTimeFormat()),
|
||||
);
|
||||
}
|
||||
|
||||
private function getFormatSeparator() {
|
||||
$format = $this->getDateFormat();
|
||||
switch ($format) {
|
||||
case 'n/j/Y':
|
||||
return '/';
|
||||
default:
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
|
||||
public function getDateTime() {
|
||||
$epoch = $this->getEpoch();
|
||||
$date = null;
|
||||
|
|
|
@ -141,6 +141,12 @@ final class PHUICalendarListView extends AphrontTagView {
|
|||
}
|
||||
|
||||
private function getEventTooltip(AphrontCalendarEventView $event) {
|
||||
$viewer = $this->getUser();
|
||||
$preferences = $viewer->loadPreferences();
|
||||
$time_pref = $preferences->getPreference(
|
||||
PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT,
|
||||
'g:i A');
|
||||
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$start = id(AphrontFormDateControlValue::newFromEpoch(
|
||||
|
@ -166,13 +172,13 @@ final class PHUICalendarListView extends AphrontTagView {
|
|||
if ($start->getValueDate() == $end->getValueDate()) {
|
||||
$tip = pht(
|
||||
'%s - %s',
|
||||
$start->getValueAsFormat('g:i A'),
|
||||
$end->getValueAsFormat('g:i A'));
|
||||
$start->getValueAsFormat($time_pref),
|
||||
$end->getValueAsFormat($time_pref));
|
||||
} else {
|
||||
$tip = pht(
|
||||
'%s - %s',
|
||||
$start->getValueAsFormat('M j, Y, g:i A'),
|
||||
$end->getValueAsFormat('M j, Y, g:i A'));
|
||||
$start->getValueAsFormat('M j, Y, '.$time_pref),
|
||||
$end->getValueAsFormat('M j, Y, '.$time_pref));
|
||||
}
|
||||
}
|
||||
return $tip;
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
* javelin-vector
|
||||
*/
|
||||
|
||||
JX.behavior('fancy-datepicker', function() {
|
||||
JX.behavior('fancy-datepicker', function(config, statics) {
|
||||
if (statics.initialized) {
|
||||
return;
|
||||
}
|
||||
statics.initialized = true;
|
||||
|
||||
var picker;
|
||||
var root;
|
||||
|
@ -16,6 +20,32 @@ JX.behavior('fancy-datepicker', function() {
|
|||
var value_m;
|
||||
var value_d;
|
||||
|
||||
var get_format_separator = function() {
|
||||
var format = get_format();
|
||||
switch (format.toLowerCase()) {
|
||||
case 'n/j/y':
|
||||
return '/';
|
||||
default:
|
||||
return '-';
|
||||
}
|
||||
};
|
||||
|
||||
var get_key_maps = function() {
|
||||
var format = get_format();
|
||||
var regex = new RegExp('[./ -]');
|
||||
return format.split(regex);
|
||||
};
|
||||
|
||||
var get_format = function() {
|
||||
var format = config.format;
|
||||
|
||||
if (format === null) {
|
||||
format = 'Y-m-d';
|
||||
}
|
||||
|
||||
return format;
|
||||
};
|
||||
|
||||
var onopen = function(e) {
|
||||
e.kill();
|
||||
|
||||
|
@ -85,18 +115,76 @@ JX.behavior('fancy-datepicker', function() {
|
|||
};
|
||||
};
|
||||
|
||||
var read_date = function() {
|
||||
var i = get_inputs();
|
||||
var date = i.d.value;
|
||||
var parts = date.split('/');
|
||||
value_y = +parts[2];
|
||||
value_m = +parts[0];
|
||||
value_d = +parts[1];
|
||||
var read_date = function(){
|
||||
var inputs = get_inputs();
|
||||
var date = inputs.d.value;
|
||||
var regex = new RegExp('[./ -]');
|
||||
var date_parts = date.split(regex);
|
||||
var map = get_key_maps();
|
||||
|
||||
for (var i=0; i < date_parts.length; i++) {
|
||||
var key = map[i].toLowerCase();
|
||||
|
||||
switch (key) {
|
||||
case 'y':
|
||||
value_y = date_parts[i];
|
||||
break;
|
||||
case 'm':
|
||||
value_m = date_parts[i];
|
||||
break;
|
||||
case 'd':
|
||||
value_d = date_parts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var write_date = function() {
|
||||
var i = get_inputs();
|
||||
i.d.value = value_m + '/' + value_d + '/' + value_y;
|
||||
var inputs = get_inputs();
|
||||
var map = get_key_maps();
|
||||
var arr_values = [];
|
||||
|
||||
for(var i=0; i < map.length; i++) {
|
||||
switch (map[i].toLowerCase()) {
|
||||
case 'y':
|
||||
arr_values[i] = value_y;
|
||||
break;
|
||||
case 'm':
|
||||
arr_values[i] = value_m;
|
||||
break;
|
||||
case 'n':
|
||||
arr_values[i] = value_m;
|
||||
break;
|
||||
case 'd':
|
||||
arr_values[i] = value_d;
|
||||
break;
|
||||
case 'j':
|
||||
arr_values[i] = value_d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var text_value = '';
|
||||
var separator = get_format_separator();
|
||||
|
||||
for(var j=0; j < arr_values.length; j++) {
|
||||
var element = arr_values[j];
|
||||
var format = get_format();
|
||||
|
||||
if ((format.toLowerCase() === 'd-m-y' ||
|
||||
format.toLowerCase() === 'y-m-d') &&
|
||||
element < 10) {
|
||||
element = '0' + element;
|
||||
}
|
||||
|
||||
if (text_value.length === 0) {
|
||||
text_value += element;
|
||||
} else {
|
||||
text_value = text_value + separator + element;
|
||||
}
|
||||
}
|
||||
|
||||
inputs.d.value = text_value;
|
||||
};
|
||||
|
||||
var render = function() {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
JX.behavior('time-typeahead', function(config) {
|
||||
var start_date_control = JX.$(config.startTimeID);
|
||||
var end_date_control = config.endTimeID ? JX.$(config.endTimeID) : null;
|
||||
var format = config.format;
|
||||
|
||||
var end_date_tampered = false;
|
||||
|
||||
|
@ -79,7 +80,7 @@ JX.behavior('time-typeahead', function(config) {
|
|||
|
||||
|
||||
function getNewValue(time) {
|
||||
var regex = /^([01]?\d)(?::([0-5]\d))?\s*((am|pm))?$/i;
|
||||
var regex = /^([0-2]?\d)(?::([0-5]\d))?\s*((am|pm))?$/i;
|
||||
|
||||
if (!regex.test(time)) {
|
||||
return null;
|
||||
|
@ -90,7 +91,28 @@ JX.behavior('time-typeahead', function(config) {
|
|||
var minutes = parseInt(results[2], 10) ? parseInt(results[2], 10) : 0;
|
||||
|
||||
var real_time = 0;
|
||||
var end_value = '';
|
||||
|
||||
var end_hours;
|
||||
var end_minutes;
|
||||
|
||||
if (format === 'H:i' && hours < 23) {
|
||||
end_hours = hours + 1;
|
||||
|
||||
if (end_hours > 9) {
|
||||
end_hours = end_hours.toString();
|
||||
} else {
|
||||
end_hours = '0' + end_hours.toString();
|
||||
}
|
||||
|
||||
if (minutes > 9) {
|
||||
end_minutes = minutes.toString();
|
||||
} else {
|
||||
end_minutes = '0' + minutes.toString();
|
||||
}
|
||||
|
||||
end_value = end_hours + ':' + end_minutes;
|
||||
} else if (format === 'g:i A') {
|
||||
if (/pm/i.test(results[3])) {
|
||||
real_time = 12*60;
|
||||
} else if (/am/i.test(results[3]) && hours == 12) {
|
||||
|
@ -102,7 +124,7 @@ JX.behavior('time-typeahead', function(config) {
|
|||
var end_time = real_time + 60;
|
||||
|
||||
var end_meridian = 'AM';
|
||||
var end_hours = Math.floor(end_time / 60);
|
||||
end_hours = Math.floor(end_time / 60);
|
||||
|
||||
if (end_hours == 12) {
|
||||
end_meridian = 'PM';
|
||||
|
@ -113,9 +135,12 @@ JX.behavior('time-typeahead', function(config) {
|
|||
end_hours = end_hours - 12;
|
||||
}
|
||||
|
||||
var end_minutes = end_time%60;
|
||||
end_minutes = (end_minutes > 9) ? end_minutes : ('0' + end_minutes);
|
||||
var end_value = end_hours + ':' + end_minutes + ' ' + end_meridian;
|
||||
end_minutes = end_time%60;
|
||||
end_minutes = (end_minutes < 9) ? end_minutes : ('0' + end_minutes);
|
||||
end_value = end_hours + ':' + end_minutes + ' ' + end_meridian;
|
||||
}
|
||||
|
||||
|
||||
return end_value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue