Commit 735ae87f87a77d9b260b341a61d6cd51674166ad
1 parent
19235aca
sending email
Showing
9 changed files
with
314 additions
and
62 deletions
Show diff stats
1 | +<?php | |
2 | + use frontend\models\Feedback; | |
3 | + use yii\web\View; | |
4 | + | |
5 | + /** | |
6 | + * @var View $this | |
7 | + * @var Feedback $model | |
8 | + */ | |
9 | + | |
10 | +?> | |
11 | + | |
12 | +<table> | |
13 | + <tbody> | |
14 | + <tr> | |
15 | + <td><b><?= \Yii::t('app', 'Name: ') ?></b></td> | |
16 | + <td><?= $model->name ?></td> | |
17 | + </tr> | |
18 | + <tr> | |
19 | + <td><b><?= \Yii::t('app', 'Phone: ') ?></b></td> | |
20 | + <td><?= $model->phone ?></td> | |
21 | + </tr> | |
22 | + <tr> | |
23 | + <td><b><?= \Yii::t('app', 'Date: ') ?></b></td> | |
24 | + <td><?= $model->date ?></td> | |
25 | + </tr> | |
26 | + <tr> | |
27 | + <td><b><?= \Yii::t('app', 'Time: ') ?></b></td> | |
28 | + <td><?= $model->time ?></td> | |
29 | + </tr> | |
30 | + <tr> | |
31 | + <td><b><?= \Yii::t('app', 'Service: ') ?></b></td> | |
32 | + <td><?= $model->service ?></td> | |
33 | + </tr> | |
34 | + <tr> | |
35 | + <td><b><?= \Yii::t('app', 'Url: ') ?></b></td> | |
36 | + <td><?= $model->url ?></td> | |
37 | + </tr> | |
38 | + </tbody> | |
39 | +</table> | ... | ... |
common/mail/feedback.php
composer.json
... | ... | @@ -34,8 +34,7 @@ |
34 | 34 | "artweb/artbox-core": "@dev", |
35 | 35 | "artweb/artbox-weblog": "@dev", |
36 | 36 | "artweb/artbox-webcomment": "@dev", |
37 | - "modernkernel/yii2-photoswipe": "*", | |
38 | - "udokmeci/yii2-phone-validator" : "dev-master" | |
37 | + "modernkernel/yii2-photoswipe": "*" | |
39 | 38 | }, |
40 | 39 | "require-dev": { |
41 | 40 | "yiisoft/yii2-debug": "~2.0.0", | ... | ... |
console/migrations/m171109_141930_add_date_service_column_to_feedback_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles adding date_service to table `feedback`. | |
7 | + */ | |
8 | +class m171109_141930_add_date_service_column_to_feedback_table extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->addColumn('feedback', 'date', $this->string()); | |
16 | + $this->addColumn('feedback', 'service', $this->string()); | |
17 | + } | |
18 | + | |
19 | + /** | |
20 | + * @inheritdoc | |
21 | + */ | |
22 | + public function down() | |
23 | + { | |
24 | + $this->dropColumn('feedback', 'date'); | |
25 | + $this->dropColumn('feedback', 'service'); | |
26 | + } | |
27 | +} | ... | ... |
console/migrations/m171109_143936_add_time_column_to_feedback_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles adding time to table `feedback`. | |
7 | + */ | |
8 | +class m171109_143936_add_time_column_to_feedback_table extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->addColumn('feedback', 'time', $this->string()); | |
16 | + } | |
17 | + | |
18 | + /** | |
19 | + * @inheritdoc | |
20 | + */ | |
21 | + public function down() | |
22 | + { | |
23 | + $this->dropColumn('feedback', 'time'); | |
24 | + } | |
25 | +} | ... | ... |
frontend/controllers/SiteController.php
1 | 1 | <?php |
2 | 2 | namespace frontend\controllers; |
3 | 3 | |
4 | - use artbox\core\models\Feedback; | |
4 | + use frontend\models\Feedback; | |
5 | 5 | use artbox\core\models\Page; |
6 | 6 | use common\models\Gallery; |
7 | 7 | use common\models\Settings; |
... | ... | @@ -126,7 +126,21 @@ |
126 | 126 | if (empty(Yii::$app->request->post())) { |
127 | 127 | throw new BadRequestHttpException(); |
128 | 128 | } else { |
129 | - $model = new Feedback(); | |
129 | + $type = Yii::$app->request->post("type"); | |
130 | + | |
131 | + $viewFileName = "feedback"; | |
132 | + $model = new Feedback(['scenario' => Feedback::SCENARIO_WRITE_US]); | |
133 | + | |
134 | + if ( $type === "write_us" ){ | |
135 | + $viewFileName = "feedback"; | |
136 | + $model = new Feedback(['scenario' => Feedback::SCENARIO_WRITE_US]); | |
137 | + } | |
138 | + elseif ( $type === "appointment" ){ | |
139 | + $viewFileName = "appointment"; | |
140 | + $model = new Feedback(['scenario' => Feedback::SCENARIO_APPOINTMENT]); | |
141 | + } | |
142 | + | |
143 | + | |
130 | 144 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
131 | 145 | |
132 | 146 | $pattern = '/([a-zA-Z0-9\._-]*@[a-zA-Z0-9\._-]*)([;\s,:]*)/'; |
... | ... | @@ -136,8 +150,9 @@ |
136 | 150 | |
137 | 151 | $emails = explode("; ", $emailStr); |
138 | 152 | |
153 | + | |
139 | 154 | $mailer->compose( |
140 | - 'feedback', | |
155 | + $viewFileName, | |
141 | 156 | [ |
142 | 157 | 'model' => $model, |
143 | 158 | ] |
... | ... | @@ -160,6 +175,8 @@ |
160 | 175 | 'alert' => $alert, |
161 | 176 | ]; |
162 | 177 | } else { |
178 | + Yii::$app->response->setStatusCode(500); | |
179 | + | |
163 | 180 | return [ |
164 | 181 | 'success' => false, |
165 | 182 | 'error' => $model->errors, | ... | ... |
frontend/models/Feedback.php
1 | 1 | <?php |
2 | + | |
2 | 3 | namespace frontend\models; |
3 | 4 | |
5 | + use Yii; | |
4 | 6 | /** |
5 | 7 | * Created by PhpStorm. |
6 | 8 | * User: timur |
7 | 9 | * Date: 09.11.17 |
8 | 10 | * Time: 14:50 |
11 | + * | |
12 | + * @property string $date | |
13 | + * @property string $service | |
14 | + * @property string $time | |
15 | + * | |
9 | 16 | */ |
10 | - | |
11 | 17 | class Feedback extends \artbox\core\models\Feedback |
12 | 18 | { |
13 | 19 | const SCENARIO_WRITE_US = "write_us"; |
... | ... | @@ -18,13 +24,12 @@ |
18 | 24 | $scenarios = array_merge( |
19 | 25 | parent::scenarios(), |
20 | 26 | [ |
21 | - self::SCENARIO_APPOINTMENT=>[ | |
27 | + self::SCENARIO_APPOINTMENT => [ | |
22 | 28 | 'name', |
23 | 29 | 'phone', |
24 | 30 | 'date', |
25 | 31 | 'time', |
26 | 32 | 'service', |
27 | - 'url' | |
28 | 33 | ], |
29 | 34 | |
30 | 35 | self::SCENARIO_WRITE_US => [ |
... | ... | @@ -32,8 +37,7 @@ |
32 | 37 | 'email', |
33 | 38 | 'phone', |
34 | 39 | 'message', |
35 | - 'url' | |
36 | - ] | |
40 | + ], | |
37 | 41 | ] |
38 | 42 | ); |
39 | 43 | |
... | ... | @@ -48,7 +52,6 @@ |
48 | 52 | 'name', |
49 | 53 | 'phone', |
50 | 54 | 'date', |
51 | - 'url' | |
52 | 55 | ], |
53 | 56 | 'required', |
54 | 57 | 'on' => self::SCENARIO_APPOINTMENT, |
... | ... | @@ -58,7 +61,6 @@ |
58 | 61 | 'name', |
59 | 62 | 'email', |
60 | 63 | 'phone', |
61 | - 'url', | |
62 | 64 | ], |
63 | 65 | 'required', |
64 | 66 | 'on' => self::SCENARIO_WRITE_US, |
... | ... | @@ -71,14 +73,16 @@ |
71 | 73 | [ |
72 | 74 | 'name', |
73 | 75 | 'date', |
74 | - 'phone', | |
76 | + 'service', | |
77 | + 'time', | |
75 | 78 | ], |
76 | 79 | 'string', |
77 | - 'max' => 255, | |
80 | + 'max' => 55, | |
78 | 81 | ], |
79 | 82 | [ |
80 | - [ 'url' ], | |
81 | - 'url' | |
83 | + [ 'phone' ], | |
84 | + 'match', | |
85 | + 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', | |
82 | 86 | ], |
83 | 87 | [ |
84 | 88 | [ 'message' ], |
... | ... | @@ -91,4 +95,24 @@ |
91 | 95 | ]; |
92 | 96 | } |
93 | 97 | |
98 | + /** | |
99 | + * @inheritdoc | |
100 | + */ | |
101 | + public function attributeLabels() | |
102 | + { | |
103 | + return [ | |
104 | + 'id' => Yii::t('core', 'id'), | |
105 | + 'name' => Yii::t('core', 'name'), | |
106 | + 'phone' => Yii::t('core', 'phone'), | |
107 | + 'created_at' => Yii::t('core', 'created_at'), | |
108 | + 'ip' => Yii::t('core', 'ip'), | |
109 | + 'url' => Yii::t('core', 'url'), | |
110 | + 'status' => Yii::t('core', 'status'), | |
111 | + 'message' => Yii::t('core', 'message'), | |
112 | + 'email' => Yii::t('core', 'email'), | |
113 | + 'service' => Yii::t('core', 'service'), | |
114 | + 'date' => Yii::t('core', 'date'), | |
115 | + ]; | |
116 | + } | |
117 | + | |
94 | 118 | } |
95 | 119 | \ No newline at end of file | ... | ... |
frontend/views/layouts/main.php
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | |
11 | 11 | use artbox\core\components\SeoComponent; |
12 | 12 | use artbox\core\helpers\ImageHelper; |
13 | - use artbox\core\models\Feedback; | |
13 | + use frontend\models\Feedback; | |
14 | 14 | use artbox\core\models\PageCategory; |
15 | 15 | use artbox\core\models\User; |
16 | 16 | use common\models\Settings; |
... | ... | @@ -27,7 +27,8 @@ |
27 | 27 | AppAsset::register($this); |
28 | 28 | $user = \Yii::$app->user->identity; |
29 | 29 | $seo = Yii::$app->get('seo'); |
30 | - $feedback = new Feedback(); | |
30 | + $feedback = new Feedback(['scenario' => Feedback::SCENARIO_WRITE_US]); | |
31 | + $appointment = new Feedback(['scenario' => Feedback::SCENARIO_APPOINTMENT]); | |
31 | 32 | $settings = Settings::getInstance(); |
32 | 33 | $controller = Yii::$app->controller; |
33 | 34 | $default_controller = Yii::$app->defaultRoute; |
... | ... | @@ -66,7 +67,19 @@ |
66 | 67 | 'name' => 'robots', |
67 | 68 | 'content' => $seo->robots, |
68 | 69 | ] |
69 | - ) | |
70 | + ); | |
71 | + | |
72 | + $this->registerJsFile( | |
73 | + '/js/jquery.maskedinput.js', | |
74 | + [ | |
75 | + 'depends' => 'yii\web\JqueryAsset' | |
76 | + ] | |
77 | + ); | |
78 | + | |
79 | + $js = <<<JS | |
80 | + $("#feedback-phone, #appointment-phone").mask("+38(999)999-99-99"); | |
81 | +JS; | |
82 | + $this->registerJs($js, View::POS_READY); | |
70 | 83 | ?> |
71 | 84 | |
72 | 85 | <?php $this->beginPage() ?> |
... | ... | @@ -374,49 +387,144 @@ _________________________________________________________ --> |
374 | 387 | </div> |
375 | 388 | <div class="modal-body"> |
376 | 389 | |
377 | - <form id="appointment-form" action="/site/appointment" method="POST" role="form"> | |
378 | - <div class="form-group field-appointment-name"> | |
379 | - <div class="on_input_"></div> | |
380 | - <label class="control-label" for="appointment-name">Имя</label> | |
381 | - <input type="text" id="appointment-name" class="form-control" name="Appointment[name]" aria-invalid="false"> | |
382 | - | |
383 | - <p class="help-block help-block-error"></p> | |
384 | - </div> | |
385 | - <div class="form-group field-appointment-name required"> | |
386 | - <div class="on_input_"></div> | |
387 | - <label class="control-label" for="appointment-name">Номер телефона</label> | |
388 | - <input type="text" id="appointment-phone" class="form-control" name="Appointment[phone]"> | |
389 | - | |
390 | - <p class="help-block help-block-error"></p> | |
391 | - </div> | |
392 | - <div class="form-group field-appointment-date required has-datepicker"> | |
393 | - <div class="on_input_"></div> | |
394 | - <label class="control-label" for="appointment-date">Дата</label> | |
395 | - <input type="text" id="appointment-date" class="form-control" name="Appointment[date]"> | |
396 | - | |
397 | - <p class="help-block help-block-error"></p> | |
398 | - </div> | |
399 | - <div class="datepicker-wr"> | |
400 | - <div id="datepicker"></div> | |
401 | - </div> | |
402 | - <div class="form-group field-appointment-time"> | |
403 | - <div class="on_input_"></div> | |
404 | - <label class="control-label" for="appointment-service">Время</label> | |
405 | - <input type="text" id="appointment-time" class="form-control" name="Appointment[time]"> | |
406 | - | |
407 | - <p class="help-block help-block-error"></p> | |
408 | - </div> | |
409 | - <div class="form-group field-appointment-service"> | |
410 | - <div class="on_input_"></div> | |
411 | - <label class="control-label" for="appointment-service">Услуга</label> | |
412 | - <input type="text" id="appointment-service" class="form-control" name="Appointment[service]"> | |
413 | - | |
414 | - <p class="help-block help-block-error"></p> | |
415 | - </div> | |
416 | - <p class="text-center"> | |
417 | - <button type="submit" class="send-form btn btn-lg btn-template-primary">Отправить</button> | |
418 | - </p> | |
419 | - </form> | |
390 | + | |
391 | + <?php | |
392 | + | |
393 | + | |
394 | + $formAppointment = ActiveForm::begin( | |
395 | + [ | |
396 | + 'id' => 'appointment-form', | |
397 | + 'method' => 'POST', | |
398 | + 'action' => '/site/feedback', | |
399 | + ] | |
400 | + ); | |
401 | + | |
402 | + echo Html::hiddenInput('type', 'appointment'); | |
403 | + echo $formAppointment->field( | |
404 | + $appointment, | |
405 | + "name", | |
406 | + [ | |
407 | + 'options' => [ | |
408 | + 'class' => 'form-group field-appointment-name', | |
409 | + ], | |
410 | + 'template' => "<div class=\"on_input_\"></div>{label}\n{input}\n", | |
411 | + 'inputOptions' => [ | |
412 | + 'id' => 'appointment-name' | |
413 | + ], | |
414 | + 'labelOptions' => [ | |
415 | + 'for' => 'appointment-name', | |
416 | + 'class' => 'control-label' | |
417 | + ], | |
418 | + ] | |
419 | + ) | |
420 | + ->label( | |
421 | + "Имя" | |
422 | + ); | |
423 | + | |
424 | + echo $formAppointment->field( | |
425 | + $appointment, | |
426 | + "phone", | |
427 | + [ | |
428 | + 'options' => [ | |
429 | + 'class' => 'form-group field-appointment-phone', | |
430 | + ], | |
431 | + 'template' => "<div class=\"on_input_\"></div>{label}\n{input}\n", | |
432 | + 'inputOptions' => [ | |
433 | + 'id' => 'appointment-phone' | |
434 | + ], | |
435 | + 'labelOptions' => [ | |
436 | + 'for' => 'appointment-phone', | |
437 | + 'class' => 'control-label' | |
438 | + ], | |
439 | + ] | |
440 | + ) | |
441 | + ->label( | |
442 | + "Номер телефона" | |
443 | + ); | |
444 | + | |
445 | + echo $formAppointment->field( | |
446 | + $appointment, | |
447 | + "date", | |
448 | + [ | |
449 | + 'options' => [ | |
450 | + 'class' => 'form-group field-appointment-date has-datepicker', | |
451 | + ], | |
452 | + 'template' => "<div class=\"on_input_\"></div>{label}\n{input}\n", | |
453 | + 'inputOptions' => [ | |
454 | + 'id' => 'appointment-date' | |
455 | + ], | |
456 | + 'labelOptions' => [ | |
457 | + 'for' => 'appointment-date', | |
458 | + 'class' => 'control-label' | |
459 | + ], | |
460 | + ] | |
461 | + ) | |
462 | + ->label( | |
463 | + "Дата" | |
464 | + ); | |
465 | + echo "<div class=\"datepicker-wr\"> | |
466 | + <div id=\"datepicker\"></div> | |
467 | + </div>"; | |
468 | + | |
469 | + echo $formAppointment->field( | |
470 | + $appointment, | |
471 | + "time", | |
472 | + [ | |
473 | + 'options' => [ | |
474 | + 'class' => 'form-group field-appointment-time', | |
475 | + ], | |
476 | + 'template' => "<div class=\"on_input_\"></div>{label}\n{input}\n", | |
477 | + 'inputOptions' => [ | |
478 | + 'id' => 'appointment-time' | |
479 | + ], | |
480 | + 'labelOptions' => [ | |
481 | + 'for' => 'appointment-time', | |
482 | + 'class' => 'control-label' | |
483 | + ], | |
484 | + ] | |
485 | + ) | |
486 | + ->label( | |
487 | + "Время" | |
488 | + ); | |
489 | + | |
490 | + echo $formAppointment->field( | |
491 | + $appointment, | |
492 | + "service", | |
493 | + [ | |
494 | + 'options' => [ | |
495 | + 'class' => 'form-group field-appointment-service', | |
496 | + ], | |
497 | + 'template' => "<div class=\"on_input_\"></div>{label}\n{input}\n", | |
498 | + 'inputOptions' => [ | |
499 | + 'id' => 'appointment-service' | |
500 | + ], | |
501 | + 'labelOptions' => [ | |
502 | + 'for' => 'appointment-service', | |
503 | + 'class' => 'control-label' | |
504 | + ], | |
505 | + ] | |
506 | + ) | |
507 | + ->label( | |
508 | + "Услуга" | |
509 | + ); | |
510 | + | |
511 | + echo Html::tag( | |
512 | + "p", | |
513 | + Html::button( | |
514 | + "Отправить", | |
515 | + [ | |
516 | + 'type' => "submit", | |
517 | + 'class' => "send-form btn btn-lg btn-template-primary" | |
518 | + ] | |
519 | + ), | |
520 | + [ | |
521 | + 'class' => "text-center" | |
522 | + ] | |
523 | + ); | |
524 | + | |
525 | + $formAppointment::end(); | |
526 | + ?> | |
527 | + | |
420 | 528 | |
421 | 529 | </div> |
422 | 530 | </div> |
... | ... | @@ -444,6 +552,8 @@ _________________________________________________________ --> |
444 | 552 | ] |
445 | 553 | ); ?> |
446 | 554 | |
555 | + <?= Html::hiddenInput('type', 'write_us');?> | |
556 | + | |
447 | 557 | <?= $form->field($feedback, 'name') |
448 | 558 | ->textInput() |
449 | 559 | ->Label('Имя'); ?> | ... | ... |
1 | +/* | |
2 | + jQuery Masked Input Plugin | |
3 | + Copyright (c) 2007 - 2015 Josh Bush (digitalbush.com) | |
4 | + Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) | |
5 | + Version: 1.4.1 | |
6 | +*/ | |
7 | +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a<g.placeholder.length?a:0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.begin<l&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}else{for(A(!0);b.begin<n&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}h()}function v(){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c===0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||32>g)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}); | |
0 | 8 | \ No newline at end of file | ... | ... |