From: Florent Bruneau Date: Sat, 8 Jan 2011 22:19:55 +0000 (+0100) Subject: Add survey edition form (lost a lot of time theming datepicker). X-Git-Tag: xorg/1.1.0~207 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d0b836c973167ef1ea7581a12e430e0f7431ad65;p=platal.git Add survey edition form (lost a lot of time theming datepicker). Signed-off-by: Florent Bruneau --- diff --git a/Makefile b/Makefile index 509ab88..2418710 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ JQUERY_PLUGINS=color form JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS))) JQUERY_UI_VERSION=1.8.7 -JQUERY_UI=core tabs widget +JQUERY_UI=core tabs datepicker widget JQUERY_UI_PATHES=$(addprefix htdocs/javascript/jquery.ui.,$(addsuffix .js,$(JQUERY_UI))) JQUERY_TMPL_VERSION=vBeta1.0.0 diff --git a/htdocs/css/base.css b/htdocs/css/base.css index 669c239..a38d408 100644 --- a/htdocs/css/base.css +++ b/htdocs/css/base.css @@ -69,4 +69,71 @@ .ui-tabs-hide { display: none; } +.ui-icon { + width: 16px; + height: 16px; +} + +.ui-datepicker { + background: #ffffff; + color: #000000; + position: absolute; +} + +.ui-datepicker a { + color: black; + text-decoration: none; + text-align: center; +} + +.ui-datepicker-header { + padding: 2px; + margin: 1px; + background: #777; + border: 1px solid; + border-color: #333; +} + +.ui-datepicker-title { + text-align: center; + height: 19px; +} + +.ui-datepicker-prev { + background: #777 url('/images/icons/resultset_previous.gif'); + position: absolute; + width: 16px; + height: 16px; + top: 4px; + left: 4px; + outline: none; + display: block; +} + +.ui-datepicker-next { + background: #777 url('/images/icons/resultset_next.gif'); + position: absolute; + width: 16px; + height: 16px; + top: 4px; + right: 4px; + outline: none; + display: block; +} + +.ui-datepicker-next span, .ui-datepicker-prev span { + display: block; + position: absolute; + text-indent: -99999px; + overflow: hidden; +} + +.ui-datepicker-week-end { + background-color: #eee; +} + +.ui-datepicker-unselectable { + color: #777; +} + /* vim: set et ts=4 sts=4 sw=4: */ diff --git a/htdocs/javascript/survey.js b/htdocs/javascript/survey.js new file mode 100644 index 0000000..abd6aca --- /dev/null +++ b/htdocs/javascript/survey.js @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2003-2011 Polytechnique.org * + * http://opensource.polytechnique.org/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + ***************************************************************************/ + +(function($) { + $.fn.extend({ + surveyQuestions: function(questions) { + var data = $('#question_base').tmpl(questions); + this.children().remove(); + data.appendTo(this); + return this; + } + }); +})(jQuery); + + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/modules/survey.php b/modules/survey.php index f40ce5b..c6a3914 100644 --- a/modules/survey.php +++ b/modules/survey.php @@ -26,8 +26,9 @@ class SurveyModule extends PLModule return array( 'survey' => $this->make_hook('index', AUTH_COOKIE), 'survey/vote' => $this->make_hook('vote', AUTH_COOKIE), - /* 'survey/result' => $this->make_hook('result', AUTH_COOKIE), 'survey/edit' => $this->make_hook('edit', AUTH_COOKIE), + /* + 'survey/result' => $this->make_hook('result', AUTH_COOKIE), 'survey/ajax' => $this->make_hook('ajax', AUTH_COOKIE), 'survey/admin' => $this->make_hook('admin', AUTH_MDP, 'admin'), 'survey/admin/edit' => $this->make_hook('adminEdit', AUTH_MDP, 'admin'), @@ -78,6 +79,7 @@ class SurveyModule extends PLModule { $this->load('survey.inc.php'); $page->addJsLink('jquery.tmpl.js'); + $page->addJsLink('survey.js'); $page->changeTpl('survey/vote.tpl'); $survey = Survey::get($name); if (is_null($survey)) { @@ -100,6 +102,28 @@ class SurveyModule extends PLModule } $page->assign('survey', $survey); } + + function handler_edit(PlPage $page, $name = null) + { + $this->load('survey.inc.php'); + $page->addJsLink('jquery.ui.core.js'); + $page->addJsLink('jquery.ui.widget.js'); + $page->addJsLink('jquery.ui.datepicker.js'); + $page->addJsLink('jquery.tmpl.js'); + $page->addJsLink('survey.js'); + $page->changeTpl('survey/edit.tpl'); + + if (!is_null($name)) { + $survey = Survey::get($name); + } else { + $survey = new Survey(); + $survey->id = null; + $survey->uid = S::user()->id(); + } + if (Post::has('save')) { + } + $page->assign('survey', $survey); + } } // vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8: diff --git a/templates/survey/edit.tpl b/templates/survey/edit.tpl new file mode 100644 index 0000000..9c6145d --- /dev/null +++ b/templates/survey/edit.tpl @@ -0,0 +1,50 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

Edition de sondage

+ +
+
+ Description du sondage + + Titre :
+ Nom :
+ + Premier jour :
+ Dernier jour :
+
+
+ +{literal} + +{/literal} + +{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *} diff --git a/templates/survey/vote.tpl b/templates/survey/vote.tpl index 5b91735..ad20cc7 100644 --- a/templates/survey/vote.tpl +++ b/templates/survey/vote.tpl @@ -40,11 +40,7 @@ //exportQuestionsToJSON()|smarty:nodefaults}; - {literal} - $(function() { - $("#question_base").tmpl(questions).appendTo("#questions"); - }); - {/literal} + $($("#questions").surveyQuestions(questions)); //]]>