Ejemplo n.º 1
0
 public function getReferenceRowScript(&$form, $appId)
 {
     $script = array();
     $script[] = "function jtSelectSource(idid, titleid, id, title) {";
     $script[] = "\t\tvar old_id = document.getElementById(idid).value;";
     $script[] = "\t\tif (old_id != id) {";
     $script[] = "\t\t\tdocument.getElementById(idid).value = id;";
     $script[] = "\t\t\tdocument.getElementById(titleid).value = title;";
     $script[] = "\t\t}";
     $script[] = "\t\tSqueezeBox.close();";
     $script[] = "\t}";
     $script[] = "function inject_refrow(table_body, table_row, appid, obj_type, obj_number){";
     $script[] = "   var htmlToElements = function(str){";
     $script[] = "      return new Element('div', {html: '<table><tbody>' + str + '</tbody></table>'}).getElement('tr');";
     $script[] = "   }";
     $script[] = "   var el = document.getElementById(table_body);";
     $script[] = "   var orderNumber = parseInt(document.getElementById('refcounter').value) + 1;";
     $script[] = "   document.getElementById('refcounter').value = orderNumber;";
     $script[] = "   var rowref = table_row + '_r_' + orderNumber;";
     // create a table row as a string
     $script[] = "   var row_str = '<tr id=\"'+rowref+'\" class=\"jt-table-entry3\">';";
     $tmp = self::getReferenceRow(false, $form, null, null, $appId);
     $htmls = explode("\n", $tmp);
     foreach ($htmls as $html) {
         $script[] = "   row_str += '" . $html . "';";
     }
     $script[] = "\trow_str += '</tr>';";
     // convert string to table wrapped in a div element
     $script[] = "\tvar newRow = htmlToElements( row_str );";
     // inject the new row into the table body
     $script[] = "\tnewRow.inject( el );";
     // setup modal
     $script[] = "   SqueezeBox.assign(\$\$('a.modal_src_'+orderNumber), { parse: 'rel' });";
     $script[] = "   var url=document.getElementById('modalid_'+orderNumber).href;";
     if (JoaktreeHelper::getSEF() == 1) {
         $script[] = "   document.getElementById('modalid_'+orderNumber).href = url+'?counter='+orderNumber;";
     } else {
         $script[] = "   document.getElementById('modalid_'+orderNumber).href = url+'&counter='+orderNumber;";
     }
     $script[] = "}";
     $script[] = " ";
     return implode("\n", $script);
 }