Enables simple datepicker for input

@return $this
1124
public function enableCalendarDatepicker()
    {
        if (!$this->isEnabledCalendarDatepicker()) {
            // First time enabling
            PageTail::getInstance()
                ->addCssUrl('plugins/datepicker/datepicker.css')
                ->addJsUrl('plugins/datepicker/bootstrap-datepicker.js');

            $this->setDateFormat('yyyy-mm-dd');
        }

        $this->calendar_datepicker_enabled = true;

        return $this;
    }
491699
protected function getInput()
	{
		// Initialize variables.
		$options = array();
		$attr = '';

		// Initialize some field attributes.
		$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
		$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
		$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
		$attr .= $this->multiple ? ' multiple="multiple"' : '';

		// Initialize JavaScript field attributes.
		$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		// Iterate through the children and build an array of options.
		foreach ($this->element->children() as $option)
		{

			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Create a new option object based on the <option /> element.
			$tmp = Dropdown::option((string) $option['value'], trim((string) $option), 'value', 'text',
				((string) $option['disabled'] == 'true')
			);

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		return Access::usergroup($this->name, $this->value, $attr, $options, $this->id);
	}
349130
function getInput()
    {
        $years = [];
        for ($i = date('Y') - $this->maxAge; $i <= date('Y') - $this->minAge; $i++) {
            $years[$i] = $i;
        }
        $value = $this->getValue();
        $year = substr($value, 0, 4);
        $monthV = substr($value, 5, 2);
        $day = substr($value, 8, 2);
        $this->htmlOptions['class'] = isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '';
        $this->htmlOptions['class'] .= $this->inputClass . ' birthday';

        $htmlOptions = $this->htmlOptions;
        $htmlOptions['class'] .= ' bday-year';
        $r = Form::get()->select('', $years, $year, $htmlOptions);

        $mths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
        $months = [];
        foreach ($mths as $k => $month) {
            $months[$k < 10 ? "0" . ($k + 1) : $k + 1] = $this->translate($month);
        }
        $htmlOptions = $this->htmlOptions;
        $htmlOptions['class'] .= ' bday-month';
        $r .= Form::get()->select('', $months, $monthV, $htmlOptions);
        $days = [];
        for ($i = 1; $i <= 31; $i++) {
            $days[$i < 10 ? "0" . $i : $i] = $i < 10 ? "0" . $i : $i;
        }
        $htmlOptions = $this->htmlOptions;
        $htmlOptions['class'] .= ' bday-day';
        $r .= Form::get()->select('', $days, $day, $htmlOptions);
        return $r . Form::get()->hiddenInput($this->getName(), $this->getValue(), ['class' => 'birthday_value']);
    }
756139
function(id, dateStr) {
		var onSelect,
			target = $(id),
			inst = this._getInst(target[0]);

		dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
		if (inst.input) {
			inst.input.val(dateStr);
		}
		this._updateAlternate(inst);

		onSelect = this._get(inst, "onSelect");
		if (onSelect) {
			onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
		} else if (inst.input) {
			inst.input.trigger("change"); // fire the change event
		}

		if (inst.inline){
			this._updateDatepicker(inst);
		} else {
			this._hideDatepicker();
			this._lastInput = inst.input[0];
			if (typeof(inst.input[0]) !== "object") {
				inst.input.focus(); // restore focus
			}
			this._lastInput = null;
		}
	}
16828
public function before($input): self {
        $this->manipulateNodesWithInput($input, function($node, $newNodes) {
            foreach ($newNodes as $newNode) {
                $node->parent()->insertBefore($newNode, $node);
            }
        });

        return $this;
    }
1073968
protected function optimizeDateFields()
    {
        if (empty($this->field->dateFormat) && $this->field->isDateOrTime()) {
            $this->field->dateFormat = Config::getDateTimeFormat();
        }

        return $this;
    }
953048
public function allow()
    {
        $roleNames = func_get_args();

        // Flatten array to allow array inputs
        $roleNames = Core::array_flatten($roleNames);

        foreach ($roleNames as $role) {

            if (!in_array($role, $this->allowedRoles)) {
                $this->allowedRoles[] = $role;
            }
        }

        return $this;
    }
1180511
public function monthInput($options = []) {
	$defaultOptions = [
		'id' => self::MONTH_ID,
		'class' => 'form-control',
		'autocomplete' => self::AUTO_MONTH_ATTR,
		'placeholder' => '••',
		'required' => true,
		'type' => 'tel',
		'maxlength' => 2,
		'size' => 2
	];
	$mergedOptions = array_merge($defaultOptions, $options);
	StripeHelper::secCheck($mergedOptions);
	$mergedOptions['data-stripe'] = self::MONTH_ID;
	return Html::input('text', null, null, $mergedOptions);
    }
544894
public function onSignin()
    {
        try {
            /*
             * Validate input
             */
            $data = post();
            $rules = [];

            $rules['login'] = $this->loginAttribute() == UserSettings::LOGIN_USERNAME
                ? 'required|between:2,255'
                : 'required|email|between:6,255';

            $rules['password'] = 'required|between:4,255';

            if (!array_key_exists('login', $data)) {
                $data['login'] = post('username', post('email'));
            }

            $validation = Validator::make($data, $rules);
            if ($validation->fails()) {
                throw new ValidationException($validation);
            }

            /*
             * Authenticate user
             */
            $credentials = [
                'login'    => array_get($data, 'login'),
                'password' => array_get($data, 'password')
            ];

            Event::fire('rainlab.user.beforeAuthenticate', [$this, $credentials]);

            $user = Auth::authenticate($credentials, true);
            if ($user->isBanned()) {
                Auth::logout();
                throw new AuthException(/*Sorry, this user is currently not activated. Please contact us for further assistance.*/'rainlab.user::lang.account.banned');
            }

            /*
             * Redirect
             */
            if ($redirect = $this->makeRedirection(true)) {
                return $redirect;
            }
        }
        catch (Exception $ex) {
            if (Request::ajax()) throw $ex;
            else Flash::error($ex->getMessage());
        }
    }
408649
public static function setBirthdays($input='')
    {
        // Skip common method parameter
        if (is_object($input) || is_array($input)) {

            return self::__callStatic($name, [$input]);
        }

        // Date format helper
        $gDate = new Google_Service_PeopleService_Date;
        $inputTime = strtotime($input);
        // Check
        if ($inputTime <= 0) {
            return new self;
        }
        $gDate->setYear(date("Y", $inputTime));
        $gDate->setMonth(date("m", $inputTime));
        $gDate->setDay(date("d", $inputTime));

        $input = ['date' => $gDate];

        return self::__callStatic(__FUNCTION__, [$input]);
    }
228440
public function defaultPickerOptions()
    {
        $date = null;

        if ($this->inputVal() !== '') {
            $date = new \DateTime($this->inputVal());
        }

        return [
            'format'      => self::DEFAULT_JS_FORMAT,
            'defaultDate' => $date ? $date->format(\DateTime::ISO8601) : null
        ];
    }
347357
protected function getInput()
	{
		// Initialize some field attributes.
		$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

		// Initialize JavaScript field attributes.
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		return '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $disabled . $onchange . ' />';
	}
208161
public function setInput($input)
    {
        if (!(is_string($input) || $input instanceof BasicFormElement)) {
            throw new Exception('Input must be a String or instance of FormElement Contract');
        }

        if (is_string($input)) {
            $input = $this->makeInput($input);
        }

        $this->input = $input;

        return $this;
    }
418029
public function datetimePicker()
    {
        $this->element = Angular::datetime('{model}', '{label}', [
            'fieldid' => $this->form->getFieldId($this->attribute),
            'ng-init' => '{initValue}',
        ]);

        return $this;
    }
820012
protected function getInput() {

        $js = [];

        $class        = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $placeholder  = $this->element['placeholder'] ? ' placeholder="' . htmlspecialchars((string) $this->element['placeholder']) . '"' : null;

        $options = [];

	    if ($this->value) {
	    	$options['initialDate'] = "##FUNC##moment('".$this->value."', 'X')##FUNC##";
	    } elseif ($this->element['initialDate']) {
		    $options['initialDate'] = "##FUNC##moment('".(string) $this->element['initialDate']."', 'X')##FUNC##";
	    }

	    if ($this->element['endDate']) {
		    $options['endDate'] = "##FUNC##moment('". (string) $this->element['endDate']."')##FUNC##";
	    }

	    if ($this->element['onChange']) {
		    $options['onChange'] = "##FUNC##" . (string) $this->element['onChange'] . "##FUNC##";
	    }

	    if ($this->element['valueFormat']) {
		    $options['valueFormat'] = "##FUNC##" . (string) $this->element['valueFormat'] . "##FUNC##";
	    }

	    if ($this->element['showWeekNumber']) {
		    $options['showWeekNumber'] = ((string) $this->element['showWeekNumber'] == "true");
	    }

	    $str = str_replace(['"##FUNC##', '##FUNC##"'], "", json_encode($options));

        $js[] = "var wp = new weekpicker('#" . $this->id . "', " . $str . ");$('#" . $this->id . "').data('weekpicker', wp);";

        (new RequireJSUtility())
            ->addRequireJSModule("moment", "js/vendor/moment.min", true)
            ->addRequireJSModule("weekpicker", "js/vendor/week-picker.min", false, ["jquery", "moment"])
            ->addDomReadyJS(implode("\n", $js), false, "moment, weekpicker, css!/css/vendor/week-picker.min.css", false);

	    $value = $this->value;
	    if (empty($value)) {
	    	$value = time();
	    }

	    return '<div class="input-group week-picker">'
                . '<input type="text" readonly id="' . $this->id . '" value="' . date('\SW Y', $value) . '"' . $placeholder . $class . '>'
                . '<span class="input-group-addon" id="' . $this->id . '_btn"><span class="fa fa-calendar"></span></span>'
             . '</div>';


    }
1267956
function(input, inst) {
		var showOn, buttonText, buttonImage,
			appendText = this._get(inst, "appendText"),
			isRTL = this._get(inst, "isRTL");

		if (inst.append) {
			inst.append.remove();
		}
		if (appendText) {
			inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
			input[isRTL ? "before" : "after"](inst.append);
		}

		input.unbind("focus", this._showDatepicker);

		if (inst.trigger) {
			inst.trigger.remove();
		}

		showOn = this._get(inst, "showOn");
		if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
			input.focus(this._showDatepicker);
		}
		if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
			buttonText = this._get(inst, "buttonText");
			buttonImage = this._get(inst, "buttonImage");
			inst.trigger = $(this._get(inst, "buttonImageOnly") ?
				$("<img/>").addClass(this._triggerClass).
					attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
				$("<button type='button'></button>").addClass(this._triggerClass).
					html(!buttonImage ? buttonText : $("<img/>").attr(
					{ src:buttonImage, alt:buttonText, title:buttonText })));
			input[isRTL ? "before" : "after"](inst.trigger);
			inst.trigger.click(function() {
				if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
					$.datepicker._hideDatepicker();
				} else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
					$.datepicker._hideDatepicker();
					$.datepicker._showDatepicker(input[0]);
				} else {
					$.datepicker._showDatepicker(input[0]);
				}
				return false;
			});
		}
	}
534115
public function withDateAtEndOfMonth() : self
    {
        $instance = $this->withDateAtStartOfMonth();
        
        $instance->date->modify('+1 month');
        $instance->date->modify('-1 day');
        
        return $instance;
    }