public function render($name, $value = array(), $attributes = array(), $errors = array())
 {
     $widget = array();
     use_javascript('jquery.tooltip/jquery.tooltip.js');
     use_stylesheet('../js/jquery.tooltip/jquery.tooltip.css');
     $widget['%thumbnails%'] = '';
     $widget['%thumbnails%'] .= '';
     $j = 0;
     foreach ($value as $j => $image) {
         if (!isset($image['id'])) {
             continue;
         }
         $fileIdInput = new sfWidgetFormInputHidden();
         $fileNameInput = new sfWidgetFormInputHidden();
         $commentInput = new sfWidgetFormInput(array(), array('maxlength' => 255));
         $largeInput = new sfWidgetFormInputHidden();
         $thumbnailInput = new sfWidgetFormInputHidden();
         $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . '<span style="display: inline; width: 260px; float: left; text-align: center; padding-top: 10px;">' . link_to($image['name'], strval($image['Large']), array('class' => 'preview', 'rel' => strval($image['Thumbnail']))) . '</span>' . '&nbsp;' . $thumbnailInput->render($name . "[" . $j . "][Thumbnail]", strval($image['Thumbnail']), array()) . $largeInput->render($name . "[" . $j . "][Large]", strval($image['Large']), array()) . $fileNameInput->render($name . "[" . $j . "][name]", $image['name'], array()) . $fileIdInput->render($name . "[" . $j . "][id]", $image['id'], array()) . '<span>Title:</span>' . $commentInput->render($name . "[" . $j . "][description]", $image['description'], array('class' => 'text  input-mercha-account')) . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="del-photo"><img src="/images/cross.gif"  style="vertical-align:middle;" /></a>' . '</div>';
     }
     $i = $j + 1;
     $fileInput = new sfWidgetFormInputFile();
     $commentInput = new sfWidgetFormInput();
     $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . $fileInput->render($name . "[" . $i . "][file]", null, array('class' => '', 'style' => "padding-left:0px;  width: 260px;  padding:0px; ")) . '&nbsp;' . '<span>Title:</span>' . $commentInput->render($name . "[" . $i . "][description]", null, array('class' => 'text  input-mercha-account')) . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="del-photo" style="vertical-align:middle;"><img src="/images/cross.gif" /></a>' . '</div>' . '<div class=" add-another-location bottom_add_new_category_link" style="padding-top: 0px; padding-bottom: 15px;">' . '<div class="plus_category">' . '<div class="left margin1"><img src="/images/plus.gif" /></div>' . '<div class="left margin_top3"><a href="#" class="add-photo">Add Another Photo</a></div>' . '</div>' . '</div>';
     $js = jq_javascript_tag("\r\n      jQuery(document).ready(function(){\r\n        i = jQuery('.upload_item').length + 1;\r\n        \r\n        jQuery('a.del-photo').live('click', function(e){\r\n          e.preventDefault();\r\n          jQuery(this).parents('.upload_item').remove();\r\n        });\r\n        \r\n        jQuery('.preview').tooltip({ \r\n            delay: 0, \r\n            showURL: false, \r\n            bodyHandler: function() { \r\n                return jQuery('<img/>').attr('src', jQuery(this).attr('rel')); \r\n            } \r\n        });\r\n        \r\n        jQuery('a.add-photo').live('click', function(e){\r\n          \r\n          e.preventDefault();\r\n          \r\n          var already = jQuery('.upload_item');\r\n          \r\n          var newUpload = '';\r\n          \r\n          var maxCount = " . intval($this->getOption('max_count')) . ";\r\n          \r\n          if ((maxCount > 0 && already.length < maxCount) || maxCount == 0) {\r\n          \r\n            newUpload = \r\n              '<div class=\\'upload_item\\' style=\\'margin-bottom: 10px;\\'><input type=\\'file\\' name=\\'" . $name . "[' + i + '][file]" . "\\' class=\"\" style=\"padding-left:0px;  width: 260px; padding:0px; \" />' +\n              '&nbsp;<span>Title:</span>' +\r\n              '<input type=\\'text\\' name=\\'" . $name . "[' + i + '][description]" . "\\' class=\\'text input-mercha-account\\' >';\r\n          \r\n            newUpload += \r\n              '&nbsp;&nbsp;&nbsp;&nbsp;<a href=\\'#\\' class=\\'del-photo\\'><img src=\\'/images/cross.gif\\'  style=\\'vertical-align:middle;\\' /></a>';\r\n          \r\n            \r\n            \r\n            newUpload += '</div>';\r\n            \r\n            jQuery(newUpload).insertBefore(jQuery(this).parents('div.add-another-location'));\r\n            i++;\r\n          }\r\n        })\r\n      \r\n      });\r\n    ");
     return $js . '<div id="uploader" style="width: 590px;">' . strtr($this->getOption('template'), $widget) . '</div>';
 }
Пример #2
0
/**
   * Periodically calls the specified url ('url') every 'frequency' seconds (default is 10).
   * Usually used to update a specified div ('update') with the results of the remote call.
   * The options for specifying the target with 'url' and defining callbacks is the same as 'link_to_remote()'.
   */
function jq_periodically_call_remote($options = array())
{
	$frequency = isset($options['frequency']) ? $options['frequency'] : 10; // every ten seconds by default
	$code = 'setInterval(function() {'.jq_remote_function($options).'}, '.($frequency * 1000).')';

	return jq_javascript_tag($code);
}
Пример #3
0
/**
 * wrapper for jquery autocompleter.
 * @param string name value of input field
 * @param string default value for the input field
 * @param string url to server script
 * @param array input tag options. (size, autocomplete, etc...)
 * @param array completion options. (use_style, etc...)
 *
 * @return string input field tag, div for completion results, and
 *                 auto complete javascript tags
 */
function jq_input_auto_complete_tag($name, $value, $url, $tag_options = array(), $completion_options = array())
{
    $context = sfContext::getInstance();
    $tag_options = _convert_options($tag_options);
    $response = sfContext::getInstance()->getResponse();
    $response->addJavascript(sfConfig::get('app_mdToolsPlugin_jquery_ui_folder', '/mdToolsPlugin/js/jquery') . '/plugins/jquery-autocomplete');
    //$comp_options = _convert_options($completion_options);
    if (isset($comp_options['use_style']) && $comp_options['use_style'] == true) {
        $response->addStylesheet(sfConfig::get('sf_prototype_web_dir') . '/css/input_auto_complete_tag');
    }
    $tag_options['id'] = get_id_from_name(isset($tag_options['id']) ? $tag_options['id'] : $name);
    $javascript = input_tag($name, $value, $tag_options);
    $javascript .= jq_javascript_tag("\$('#" . $name . "').autocomplete('{$url}', " . _jq_options_for_javascript($completion_options) . ");");
    if (isset($comp_options['hidden_value']) && $comp_options['hidden_value'] == true) {
        $javascript .= input_hidden_tag($name . '_value');
        $javascript .= jq_javascript_tag('$(\'#' . $name . '\').result(function(event, data, formatted) {$(\'#' . $name . '_value\').val(data[1]);});');
    }
    return $javascript;
}
Пример #4
0
    <input type="text" name="title"/>
    <input type="submit" id="rr_form_submit" value="Add Role"/>
    <?php 
echo jq_button_to_function('New Role', "resetForm()", array('style' => 'display:none', 'id' => 'rr_form_new'));
?>
  </form>
  
  <div id="roles">
  <?php 
include_partial('role/list', array('role_list' => $role_list, 'max_array' => $max_array, 'max' => $max, 'pager' => $pager, 'page' => $page));
?>
  </div>
</div>

<?php 
jq_javascript_tag();
?>
function navigate(page)
{
  page = parseInt(page);
  <?php 
echo jq_remote_function(array('url' => 'role/list', 'with' => "{ page: page }", 'before' => "\$('#indicator').show();", 'success' => "\$('#indicator').hide(); \$('#roles').html(data);"));
?>
}

function resetForm()
{
  $('#rr_form input=[name=id], #rr_form input=[name=title]').val('');
  $('#rr_form_submit').val('Add Role');
  $('#rr_form_new').hide();
}
Пример #5
0
<div class="wrap"><label
	for="<?php 
echo $form['mission_email_optin']->renderId();
?>
"> <?php 
echo $form['mission_email_optin']->renderLabelName();
?>
(<a href="#"
	onclick="$('#mission_email_optin_help').dialog('open'); return false;">Help</a>)
</label>
<div id="mission_email_optin_help" title="Help"><?php 
echo $form['mission_email_optin']->renderHelp();
?>
</div>
<?php 
echo jq_javascript_tag("\$(function(){ \$('#mission_email_optin_help').dialog({ autoOpen: false }); });");
echo $form['mission_email_optin'];
?>
 <?php 
echo $form['mission_email_optin']->renderError();
?>
</div>
<div class="wrap">
        <?php 
echo $form['ccard_number']->renderLabel();
?>
                <?php 
echo $form['ccard_number'];
?>
	<?php 
echo $form['ccard_number']->renderError();
Пример #6
0
    echo $invoiceItemForm['quantity']->render(array('class' => 'error'), ESC_RAW);
} else {
    echo $invoiceItemForm['quantity']->render(array(), ESC_RAW);
}
?>
</td>
  <td class="right taxes_td">
    <span id="<?php 
echo $rowId;
?>
_taxes" class="taglist taxes">
      <?php 
$err = $invoiceItemForm['taxes_list']->hasError() ? 'error' : '';
$item_taxes = $invoiceItemForm['taxes_list']->getValue() ? $invoiceItemForm['taxes_list']->getValue() : array();
$totalTaxesValue = Doctrine::getTable('Tax')->getTotalTaxesValue($item_taxes);
echo jq_javascript_tag("\n        window.new_item_tax_index = \$('" . $rowId . "_taxes').find('span[id^=tax_" . $rowId . "]').size()+1;\n        ");
echo jq_link_to_remote(__("Add"), array('update' => $rowId . '_taxes', 'url' => 'common/ajaxAddInvoiceItemTax', 'position' => 'bottom', 'method' => 'post', 'with' => "{item_tax_index: new_item_tax_index++, invoice_item_key: '{$rowId}'}"));
foreach ($item_taxes as $taxId) {
    include_partial('common/taxSpan', array('taxKey' => $taxId, 'rowId' => $rowId, 'err' => $err));
}
?>

      <?php 
// if item has no taxes, and there are "default" taxes defined, we add them
if (isset($isNew) && !count($item_taxes)) {
    $default_taxes = Doctrine::getTable('Tax')->createQuery()->where('active', true)->where('is_default', true)->execute();
    foreach ($default_taxes as $taxx) {
        echo javascript_tag(jq_remote_function(array('update' => $rowId . '_taxes', 'url' => 'common/ajaxAddInvoiceItemTax', 'position' => 'bottom', 'method' => 'post', 'with' => "{\n                                        item_tax_index:   new_item_tax_index++, \n                                        invoice_item_key: '{$rowId}',\n                                        selected_tax:     '" . $taxx->id . "'\n                                      }")));
    }
}
?>
Пример #7
0
          <input type="hidden" name="sf_method" value="put" />
        <?php 
}
?>
        <?php 
echo $comment_form->renderHiddenFields();
?>
        <div class="columns">
          <div class="column left">
            <div class="group">
              <label class="label"><?php 
echo __('Insert a comment');
?>
</label><br/>
              <?php 
echo $comment_form['body']->render(array('rows' => '3', 'cols' => '35'));
?>
            </div>
            <div class="group">
              <input type="submit" class="button" value="Save" />
            </div>
          </div>
          <div class="column right" id="comment_list"></div>
          <?php 
echo jq_javascript_tag(jq_remote_function(array('update' => 'comment_list', 'url' => 'idComment/index?issue_id=' . $issue->getId())));
?>
        </div>
        <div class="clear"></div>
      </form>
    </div>
  </div>