From af42f0b2d035afba9f629f48c49541b16dff8ad1 Mon Sep 17 00:00:00 2001 From: atnartur Date: Fri, 28 Aug 2015 23:29:29 +0300 Subject: [PATCH 1/5] =?UTF-8?q?+=20=D0=92=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8?= =?UTF-8?q?=D1=86=D1=83=20=D0=B7=D0=BE=D0=BD=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=88=D0=B8=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B8=20=D0=B2=D1=8B=D1=81=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql_dump.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql_dump.sql b/sql_dump.sql index bfd9e3c..1caa510 100644 --- a/sql_dump.sql +++ b/sql_dump.sql @@ -55,8 +55,10 @@ CREATE TABLE IF NOT EXISTS `user_tokens` ( ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `zones` ( -`id` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL + `id` int(10) unsigned NOT NULL, + `name` varchar(255) NOT NULL, + `height` INT(11) NOT NULL, + `width` INT(11) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `views` ( From 2f69ebc3cf89b9e2db87e0e466c07e4d796187e5 Mon Sep 17 00:00:00 2001 From: atnartur Date: Fri, 28 Aug 2015 23:31:28 +0300 Subject: [PATCH 2/5] =?UTF-8?q?+=20Zones=20model=20-=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D1=8B=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Zones.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/Zones.php b/app/models/Zones.php index 3b78532..fe3d8a3 100644 --- a/app/models/Zones.php +++ b/app/models/Zones.php @@ -4,9 +4,11 @@ class Zones extends ModelBase { - public $id, $name; + public $id, $name, $height, $width; public $labels = array( - 'name' => 'Имя' + 'name' => 'Имя', + 'height' => 'Высота', + 'width' => 'Ширина' ); public function initialize() From 8722fc7c9c9fb72f6e94e97e0f02dfcea4d43539 Mon Sep 17 00:00:00 2001 From: atnartur Date: Fri, 28 Aug 2015 23:33:43 +0300 Subject: [PATCH 3/5] =?UTF-8?q?+=20=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=BE=D0=B2=20=D0=B7=D0=BE=D0=BD?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/zones/index.phtml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/admin/zones/index.phtml b/app/views/admin/zones/index.phtml index 49db605..719fb7f 100644 --- a/app/views/admin/zones/index.phtml +++ b/app/views/admin/zones/index.phtml @@ -5,7 +5,7 @@
-
+
Список
@@ -22,6 +22,7 @@ ID Имя Код инициализации зоны + Размеры Действия @@ -33,6 +34,7 @@ id}\">
");?> + width == '' ? '???' : $zone->width?>xheight == '' ? '???' : $zone->height?> From 982bbd3824a2d1dada3bcf51d237cca7e76bc71a Mon Sep 17 00:00:00 2001 From: atnartur Date: Fri, 28 Aug 2015 23:36:22 +0300 Subject: [PATCH 4/5] =?UTF-8?q?+=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B7=D0=BE=D0=BD=D1=8B=20=D0=BF=D1=80=D0=B8=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8/=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/Admin/ZonesController.php | 4 ++-- app/views/admin/zones/edit.phtml | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/Admin/ZonesController.php b/app/controllers/Admin/ZonesController.php index 3a0825c..153ffc0 100644 --- a/app/controllers/Admin/ZonesController.php +++ b/app/controllers/Admin/ZonesController.php @@ -17,7 +17,7 @@ public function addAction() { $zone = new Zones(); if ($this->request->isPost()) { - if($zone->save($this->request->getPost(), array('name'))) + if($zone->save($this->request->getPost(), array('name', 'width', 'height'))) { $this->flashSession->success("Зона успешно создана"); return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones')); @@ -63,7 +63,7 @@ public function editAction() { { if ($this->request->isPost()) { - if($zone->save($this->request->getPost(), array('name'))) + if($zone->save($this->request->getPost(), array('name', 'width', 'height'))) { $this->flashSession->success("Зона отредактирована"); return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones')); diff --git a/app/views/admin/zones/edit.phtml b/app/views/admin/zones/edit.phtml index 09e1a98..e5ec8f0 100644 --- a/app/views/admin/zones/edit.phtml +++ b/app/views/admin/zones/edit.phtml @@ -17,7 +17,23 @@ tag->textField(array('name', 'value'=>$zone->name, 'class'=>'form-control'))?>
- +
+ +
+ tag->textField(array( + 'width', + 'value'=>$zone->width, + 'class'=>'form-control', + 'placeholder'=>'Ширина' + ))?> + tag->textField(array( + 'height', + 'value'=>$zone->height, + 'class'=>'form-control', + 'placeholder'=>'Высота' + ))?> +
+
From 38f5fb8a825931b8770159b1ee7eec68dc67573f Mon Sep 17 00:00:00 2001 From: atnartur Date: Fri, 28 Aug 2015 23:53:36 +0300 Subject: [PATCH 5/5] =?UTF-8?q?+=20=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B7=D0=BE=D0=BD=D1=8B=20=D0=B8=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D0=B5=D1=80=D0=B0=20=D0=BD=D0=B0=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=BD=D0=BD=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/Admin/BannersController.php | 6 ++++-- app/views/admin/banners/edit.phtml | 10 ++++++++-- public/js/banners_edit_sizes.js | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 public/js/banners_edit_sizes.js diff --git a/app/controllers/Admin/BannersController.php b/app/controllers/Admin/BannersController.php index cbfa47c..ba81727 100644 --- a/app/controllers/Admin/BannersController.php +++ b/app/controllers/Admin/BannersController.php @@ -30,7 +30,8 @@ public function addAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $banner = new Banners(); @@ -123,7 +124,8 @@ public function editAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $id = $this->dispatcher->getParam('id'); diff --git a/app/views/admin/banners/edit.phtml b/app/views/admin/banners/edit.phtml index 75472bb..aeb5a1a 100644 --- a/app/views/admin/banners/edit.phtml +++ b/app/views/admin/banners/edit.phtml @@ -118,8 +118,14 @@ $zones = \App\Models\Zones::find(); foreach($zones as $zone):?>
-
diff --git a/public/js/banners_edit_sizes.js b/public/js/banners_edit_sizes.js new file mode 100644 index 0000000..cc68e0a --- /dev/null +++ b/public/js/banners_edit_sizes.js @@ -0,0 +1,21 @@ +function init() { + var banner_w = Number($('input#width').val()); + var banner_h = Number($('input#height').val()); + + $('.zone').each(function(){ + var h = Number($(this).find('#height').text()); + var w = Number($(this).find('#width').text()); + + if (w >= banner_w && h >= banner_h) + $(this).find('.status').text('входит в размер этой зоны'); + else + $(this).find('.status').text('не входит в размер этой зоны'); + }); +} + +$(document).ready(function(){ + init(); + $('input#width, input#height').change(function(){ + init(); + }) +}); \ No newline at end of file