You are here

function theme_cmis_browser_folder_picker in CMIS API 7

Same name and namespace in other branches
  1. 6.4 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_folder_picker()
  2. 6.3 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_folder_picker()
  3. 7.2 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_folder_picker()

Theme for cmis_browser folder picker widget.

Parameters

$textfield_element:

File

cmis_browser/cmis_browser.theme.inc, line 181

Code

function theme_cmis_browser_folder_picker($variables) {
  drupal_add_css(drupal_get_path('module', 'cmis_browser') . '/css/cmis_browser.css');
  drupal_add_js(drupal_get_path('module', 'cmis_browser') . '/js/jquery.tree.min.js');
  drupal_add_js('
  $(document).ready(function(){
    $("#' . $variables['textfield_element']['#id'] . '-cmis-picker")
      .find("div.form-item").css("display","inline").end()
      .find("a:first").click(function() {
        $(".tree",$(this).parent()).toggle();
      }).end()
      .find(".tree").tree({
        callback: {
          onselect: function(node, tree) {
            var text_element = $("#' . $variables['textfield_element']['#id'] . '");
            text_element.attr("value", "/");
            ($(node).attr("rel")=="folder"?$(node).children():$(node))
              .parents("li").map(function(el){
                text_element.attr("value",
                  "/" + $.trim($("a:first", $(this)).text()) + text_element.attr("value"));
              }); tree.container.toggle();
          }
        },
        ui:{dots:false},
        data:{
          type: "json", async:true, opts: {url: "' . url('cmis/tree') . '"}
        },
        types:{
          "default": {draggable: false, deletable: false, renameable: false},
          "folder": {
            valid_children : [ "document" ],
            icon: {
              image: "' . url(drupal_get_path('module', 'cmis_browser')) . '/images/space.gif"
            }
          },
          "document": {
            valid_children: "none", max_children: 0, max_depth: 0,
            icon: {
              image: "' . url(drupal_get_path('module', 'cmis_browser')) . '/images/file.png"
            },
          }
        }
      }).css("width", $("#' . $variables['textfield_element']['#id'] . '").attr("offsetWidth").toString()+"px")
  });', 'inline');
  return '<div id="' . $variables['textfield_element']['#id'] . '-cmis-picker" style="display:block">' . theme('textfield', array(
    'element' => $variables['textfield_element'],
  )) . '<a href="#"> Tree </a>' . '<div class="tree" style="display:none"></div>' . '</div>';
}