Changeset 64 for Dev/trunk/classes
- Timestamp:
- 08/02/11 11:58:29 (14 years ago)
- Location:
- Dev/trunk/classes
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SessionCreationTool.php
r61 r64 8 8 class SessionCreationTool { 9 9 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(); 11 19 ?> 20 12 21 <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> 14 31 </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" /> 15 156 <?php 16 157 } -
Dev/trunk/classes/SurveyCreationTool.php
r61 r64 34 34 private static function javascript($id = null) { 35 35 ?> 36 <script type="text/javascript" src="js/creation.js"></script> 36 37 <script type="text/javascript"> 37 38 /* autosave every 3 minutes */ … … 75 76 return questionDiv; 76 77 } 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 }114 78 115 79 function handleType(select, answers) … … 397 361 $value = 'Untitled Survey'; 398 362 ?> 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)" /> 400 364 <?php 401 365 } … … 419 383 $value = 'Write a helpful description for this survey here.'; 420 384 ?> 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> 422 386 <?php 423 387 }
Note: See TracChangeset
for help on using the changeset viewer.