diff --git a/media/js/student/index.js b/media/js/student/index.js index 31876579bd23537e3d997210e661e7fbe38432fa..b5c439f5c490248578f468887876725697cee101 100644 --- a/media/js/student/index.js +++ b/media/js/student/index.js @@ -1,10 +1,6 @@ -$(function() { - - $('#openHelp').click(function() - { - $.get(URLdir + "window/help:student:index", function(data){ - wnd.open(JSON.parse(data)); - }); +$(function () { + $('#openHelp').click(function () { + $.postJSON(URLdir + 'window/help:student:index') + .done(data => wnd.open(data)) }); - }); \ No newline at end of file diff --git a/media/js/wnd/wnd.js b/media/js/wnd/wnd.js index ff5a87124632f5b7ea4c4176cbb62c5400c16bd5..a89f454f897a6bc75bd2ab2a06d4628a48ec8a63 100644 --- a/media/js/wnd/wnd.js +++ b/media/js/wnd/wnd.js @@ -1,41 +1,44 @@ -var wnd = {} -wnd.$ = {} +var wnd = {}; +wnd.$ = {}; wnd.isShow = false; wnd.show = function () { - wnd.isShow = true; - wnd.scroll = $(window).scrollTop(); - wnd.$.page.css("position", "fixed"); - wnd.$.page.css("margin-top", -wnd.scroll); - wnd.$.window.fadeIn("fast"); -} + wnd.isShow = true; + wnd.scroll = $(window).scrollTop(); + wnd.$.page.css({ position: 'fixed', 'margin-top': -wnd.scroll }); + wnd.$.window.fadeIn("fast"); +}; + wnd.hide = function () { - wnd.isShow = false; - wnd.$.page.css("position", "static"); - wnd.$.page.css("margin-top", 0); - $(window).scrollTop(wnd.scroll); - wnd.$.window.fadeOut("fast"); -} - -wnd.open = function(data) { - wnd.$.title.html(data.title || ''); - wnd.$.content.html(data.content || ''); - wnd.$.block.width(data.width || 600); - wnd.$.block.css("top", data.top || '15%'); - - wnd.show(); - - wnd.$.window.css("min-width", wnd.$.block.width() + 40); - wnd.$.window.css("min-height", wnd.$.block.height() + 50); -} + wnd.isShow = false; + wnd.$.page.css({ position: 'static', 'margin-top', 0 }); + $(window).scrollTop(wnd.scroll); + wnd.$.window.fadeOut("fast"); +}; + +wnd.open = function ([title = '', width = 600, top = '15%', content = '']) { + wnd.$.title.html(title); + wnd.$.content.html(content); + wnd.$.block.width(width); + wnd.$.block.css("top", top); + + wnd.show(); + + wnd.$.window.css({ + 'min-width': wnd.$.block.width() + 40, + 'min-height': wnd.$.block.height() + 50 + }); +}; + wnd.close = wnd.hide; -$(function() { - // Блок РѕРєРЅР° - $("body").append("<div class=\"window\"><div class=\"window-shadow\" onclick=\"wnd.close()\"></div><div class=\"window-block\"><div class=\"window-title\"></div><a href=\"javascript:wnd.close()\" class=\"window-close\"></a><div class=\"window-content\"></div></div></div>"); - wnd.$.page = $(".page"); - wnd.$.window = $(".window"); - wnd.$.block = $(".window-block"); - wnd.$.title = $(".window-title"); - wnd.$.content = $(".window-content"); +$(function () { + // Блок РѕРєРЅР° + $("body").append("<div class=\"window\"><div class=\"window-shadow\" onclick=\"wnd.close()\"></div><div class=\"window-block\"><div class=\"window-title\"></div><a href=\"javascript:wnd.close()\" class=\"window-close\"></a><div class=\"window-content\"></div></div></div>"); + + wnd.$.page = $(".page"); + wnd.$.window = $(".window"); + wnd.$.block = $(".window-block"); + wnd.$.title = $(".window-title"); + wnd.$.content = $(".window-content"); }); diff --git a/~dev_rating/application/classes/Controller/Window.php b/~dev_rating/application/classes/Controller/Window.php index a3df0b2cfede3eb6284cee8354749cceaf270e46..2605ccf1635fe2963f2654f5089f3243a3acfaa0 100644 --- a/~dev_rating/application/classes/Controller/Window.php +++ b/~dev_rating/application/classes/Controller/Window.php @@ -13,18 +13,14 @@ class Controller_Window extends Controller public function action_get() { $path = UTF8::str_ireplace(':', '/', $this->request->param('id')); - if (Kohana::find_file('views/popup', $path, 'twig')) { - $twig = Twig::factory('popup/' . $path); - $twig->User = $this->user; - $arr = explode('||', $twig->render()); - $json = json_encode(array( - 'title' => $arr[0], - 'width' => $arr[1], - 'top' => $arr[2], - 'content' => $arr[3])); - $this->response->body($json); - } else { + + if (!Kohana::find_file('views/popup', $path, 'twig')) throw HTTP_Exception::factory(404, "Рскомый шаблон $path РЅРµ найден"); - } + + $twig = Twig::factory('popup/' . $path) + ->set('User', $this->user); + + // title, width, top, content + $this->response->body(json_encode(explode('||', $twig->render()))); } }