Changeset 64


Ignore:
Timestamp:
08/02/11 11:58:29 (14 years ago)
Author:
fpvanagthoven
Message:

Start at SessionCreationTool?.

Location:
Dev/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/SessionCreationTool.php

    r61 r64  
    88class SessionCreationTool {
    99
    10     public function __construct() {
     10    private $session;
     11    private $surveys;
     12
     13    public function __construct($session = null) {
     14        $this->session = $session;
     15
     16        $this->init();
     17
     18        $this->javascript();
    1119        ?>
     20
    1221        <div class="creation">
    13             lo
     22            <form id="sessionCreationForm" action="" method="post">
     23                <?php
     24                $this->title();
     25                $this->description();
     26                $this->pipeline();
     27
     28                $this->makeSessionButton();
     29                ?>
     30            </form>
    1431        </div>
     32        <?php
     33    }
     34
     35    private function init() {
     36        $this->surveys = Loader::loadSurveys();
     37    }
     38
     39    private function javascript() {
     40        ?>
     41        <script type="text/javascript" src="js/creation.js"></script>
     42        <script type="text/javascript">
     43            var surveys = new Array();
     44                                                                                   
     45            init();
     46                                                                                               
     47            function init() {
     48                loadSurveys();
     49                loadApplications();
     50            }
     51                                                                                               
     52            function loadSurveys() {
     53        <?php
     54        foreach ($this->surveys as $survey) {
     55            ?>
     56                        var title = <?php echo "'" . $survey->title . "'"; ?>;
     57                        var id = <?php echo "'" . $survey->id . "'"; ?>;
     58                        var survey = new Survey(title, id);
     59                        surveys.push(survey);
     60            <?php
     61        }
     62        ?>
     63            }
     64                                                                                   
     65            function loadApplications() {
     66                                                                                       
     67            }
     68                                                                                   
     69            function Survey(title, id)
     70            {
     71                this.title = title;
     72                this.id = id;
     73            }
     74                                                                                   
     75            // =============================================================
     76                                                                                   
     77            function addSurvey() {
     78                var surveyList = document.createElement("select");
     79                surveyList.setAttribute("size", "1000");
     80                surveyList.className = "toLoad";
     81               
     82                for (var i = 0; i < surveys.length; i++)
     83                {
     84                    var option = document.createElement("option");
     85                    option.setAttribute("value", surveys[i].id);
     86                    option.innerHTML = surveys[i].title;
     87                    surveyList.appendChild(option);
     88                }
     89                                                                                       
     90                var sessionCreation = document.getElementById("sessionCreationForm");
     91                var pipelineOptions = document.getElementById("pipelineOptions");
     92                                                                                       
     93                sessionCreation.replaceChild(surveyList, pipelineOptions);
     94            }
     95                                                                                           
     96        </script>
     97        <?php
     98    }
     99
     100    private function title() {
     101        if (isset($this->session->title))
     102            $value = $this->session->title;
     103        else
     104            $value = 'Untitled Session';
     105        ?>
     106        <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
     107        <?php
     108    }
     109
     110    private function description() {
     111        if (isset($this->session->description))
     112            $value = $this->session->description;
     113        else
     114            $value = 'Write a description for this session here.';
     115        ?>
     116        <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
     117        <?php
     118    }
     119
     120    private function pipeline() {
     121        ?>
     122        <h2 id="pipelineHead">Pipeline</h2>
     123        <div id="pipeline" class="padding2em">
     124            <i>-Empty- </i>
     125        </div>
     126        <div id="pipelineOptions">
     127            <?php
     128            $this->addSurveyToPipelineButton();
     129            $this->addApplicationToPipelineButton();
     130            $this->addDashboardToPipelineButton();
     131            ?></div>
     132        <?php
     133    }
     134
     135    private function addSurveyToPipelineButton() {
     136        ?>
     137        <input type="button" id="surveyToPipeline" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Survey" onclick="addSurvey()"/>
     138        <?php
     139    }
     140
     141    private function addApplicationToPipelineButton() {
     142        ?>
     143        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Application" />
     144        <?php
     145    }
     146
     147    private function addDashboardToPipelineButton() {
     148        ?>
     149        <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" />
     150        <?php
     151    }
     152
     153    private function makeSessionButton() {
     154        ?>
     155        <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" />
    15156        <?php
    16157    }
  • Dev/trunk/classes/SurveyCreationTool.php

    r61 r64  
    3434    private static function javascript($id = null) {
    3535        ?>
     36        <script type="text/javascript" src="js/creation.js"></script>
    3637        <script type="text/javascript">
    3738            /* autosave every 3 minutes */
     
    7576                return questionDiv;
    7677            }
    77                                                                                                                                                                                                                                                                                                                                                    
    78             function handleFocus(input)
    79             {
    80                 /* this is such ugly code it makes me sad */
    81                 /* because it is hard coded. */
    82                 if (input.clicked == null &&
    83                     (input.value == "Untitled Survey"
    84                     || input.value == "Write a helpful description for this survey here."
    85                     || input.value == "Write a question description here."
    86                     || input.value == "Untitled Question"))
    87                 {
    88                     input.value = "";
    89                     input.style.color = "black";   
    90                     input.clicked = true;
    91                 }
    92             }
    93                                                                                                                                                                                                                                                                                                                                                                                    
    94             function handleBlur(input)
    95             {       
    96                 var surveyTitle = document.getElementById('surveyTitle');
    97                 var surveyDescription = document.getElementById('surveyDescription');
    98                                                                                                                                                                                                                                                                                                                                                                    
    99                 if (input.value == "")
    100                 {
    101                     input.style.color = "gray";
    102                     input.clicked = null;
    103                                                                                                                                                                                                                                                                                                                                                                                            
    104                     if (input == surveyTitle)
    105                     {
    106                         input.value = "Untitled Survey";
    107                     }
    108                     else if (input == surveyDescription)
    109                     {
    110                         input.value = "Write a helpful description for this survey here.";
    111                     }
    112                 }                           
    113             }
    11478                                                                                                                                                                                                                                                                                                                                   
    11579            function handleType(select, answers)
     
    397361            $value = 'Untitled Survey';
    398362        ?>
    399         <input type="text" id="surveyTitle" name="surveyTitle" value="<?php echo $value ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
     363        <input type="text" id="surveyTitle" class="titleBox" name="surveyTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
    400364        <?php
    401365    }
     
    419383            $value = 'Write a helpful description for this survey here.';
    420384        ?>
    421         <textarea id="surveyDescription" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
     385        <textarea id="surveyDescription" class="descriptionBox" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
    422386        <?php
    423387    }
  • Dev/trunk/css/awesome.css

    r61 r64  
    126126
    127127.creation {
     128    position: relative;
    128129    min-height: 10em;
    129130    background-image: url('../images/bg/graygradient.png');
     
    145146
    146147#surveyTitle {
     148
     149}
     150
     151#surveyTitle:hover {
     152
     153}
     154
     155.titleBox {
    147156    width: 17em;
    148157    font-size: large;
     
    150159}
    151160
    152 #surveyTitle:hover {
     161.titleBox:hover {
    153162    color: black;
    154163}
    155164
    156165#surveyDescription {
     166
     167}
     168
     169.descriptionBox {
    157170    display: block;
    158171    width: 30em;
     
    309322/* ##################################################################
    310323   ===================== STYLESHEET OF GLORY ======================== */
     324.padding2em {
     325    padding: 2em;
     326}
    311327
    312328.topMargin {
     
    316332.leftPadding {
    317333    padding-left: 2em;
     334}
     335
     336.leftPadding1 {
     337    padding-left: 1em;
    318338}
    319339
     
    332352}
    333353
     354.nextLine {
     355    display: block;
     356}
     357
     358.leftAlign {
     359    text-align: left;
     360}
     361
    334362/* ##################################################################
    335363   ===================== STYLESHEET OF GLORY ======================== */
     
    361389    font-size: small;
    362390}
     391
     392/* ##################################################################
     393   ===================== STYLESHEET OF GLORY ======================== */
     394#pipelineHead {
     395    margin-top: 1em;
     396    text-shadow: #fff 0px 0px 1px;
     397}
     398
     399#pipeline {
     400
     401}
     402
     403.pipelineButton {
     404    width: 15em;
     405}
     406
     407#makeSessionButton {
     408    position: absolute;
     409    top: 2.3em;
     410    right: 2.3em;
     411    padding-left: 1em;
     412    padding-right: 1em;
     413}
  • Dev/trunk/mainmenu.php

    r59 r64  
    2323    redirect('index.php');
    2424
    25 $surveys = array();
    26 
    27 $surveyDBI = new SurveyDatabaseInterface(null);
    28 $surveyIDTitles = $surveyDBI->getExistingSurveys();
    29 
    30 
    31 foreach ($surveyIDTitles as $id => $title) {
    32     $survey = new Survey($id, $title);
    33     array_push($surveys, $survey);
    34 }
     25$surveys = Loader::loadSurveys();
    3526?>
    3627
Note: See TracChangeset for help on using the changeset viewer.