Author: garak
Date: 2010-05-24 18:01:06 +0200 (Mon, 24 May 2010)
New Revision: 29606

Added:
   plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/util.js
Modified:
   plugins/sfAssetsLibraryPlugin/branches/1.3/README
   plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/widget/sfWidgetFormAssetInput.class.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_actions.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_form.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_edit.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_list.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_search.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_sort.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/massUploadSuccess.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/tinyConfigMediaSuccess.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/test/data/fixtures/02_assets.yml
   
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/web/css/media.css
   plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/main.js
   plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/popup.js
Log:
[sfAssetsLibraryPlugin] changed all javascript to be unobtrusive; updated 
README accordingly


Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/README
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/README   2010-05-24 15:53:35 UTC 
(rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/README   2010-05-24 16:01:06 UTC 
(rev 29606)
@@ -201,38 +201,44 @@
 
     [php]
     <?php use_helper('sfAsset') ?>
+    <?php use_javascript('tiny_mce/tiny_mce') /* must point to your actual 
path of tinyMCE */ ?>
     <?php echo init_asset_library() ?>
 
 The next thing to do is to pass a special JavaScript callback function to the
-TinyMCE object at initialization. This is done with the `tinymce_options` 
option
-of the `textarea_tag()` helper:
+TinyMCE object at initialization. This should be done in you tinyMCE's 
configuration file:
 
-    [php]
-    <?php echo textarea_tag('content', '', array(
-      'rich' => true,
-      'tinymce_options' => 
'file_browser_callback:"sfAssetsLibrary.fileBrowserCallBack"',
-    )) ?>
+    [javascript]
+    tinyMCE.init({
+      theme : "advanced",
+      mode: "textareas",
+      editor_selector : "rich",
+      file_browser_callback : 'sfAssetsLibrary.fileBrowserCallBack'
+    });
 
+If you use the configuration above, you can add tinyMCE to all your textarea's 
with class
+"rich" (with generator.yml in admin generator, or with form templates 
otherwise).
+
 That's it, the TinyMCE file browser is now the sfAssetsLibrary's one.
 
 >**TIP**: For use with an admin generated module, place the 
 >`init_asset_library()` call
->in the `_edit_header.php` partial in the `templates/` directory of the module.
->To define the callback in a `generator.yml`, do as follows:
+>in the `_assets.php` partial in the `templates/` directory of the module. If 
you miss
+>that template, just copy it from the cache auto-generated module.
+>To add class in a `generator.yml`, do as follows:
 
     [yml]
     generator:
-      class:              sfPropelAdminGenerator
+      class:              sfPropelGenerator
       param:
         model_class:      Post
-        theme:            default
+        theme:            admin
 
-        edit:
+        config:
           fields:
-            content: { params: rich=true 
tinymce_options=\'file_browser_callback:"sfAssetsLibrary.fileBrowserCallBack"\' 
}
+            content: { class: rich }
 
 
-Using the Assets Library `input_file` helper
---------------------------------------------
+Using the form's widget
+-----------------------
 
 Traditionally, when an asset has to be referenced in a form, a file input is 
used
 (`<input type='file'>`). It allows the user to upload a file from his computer 
to
@@ -240,15 +246,19 @@
 
 Using the `sfAssetsLibraryPlugin`, you can change this control into some sort 
of
 file input that refers to the assets library, or, to put it differently, to the
-files located on the server in `web/media`. The plugin comes with a special 
helper
-for that purpose, the `input_sf_asset_tag()`. Use is just like a regular 
`input_tag()`:
+files located on the server in `web/media`. The plugin comes with a special 
widget
+for that purpose, the `sfWidgetFormAssetInput`. Use is just like a regular 
widget:
 
     [php]
-    <?php use_helper('sfAsset') ?>
-    <?php echo form_tag('foo/bar') ?>
-      <?php echo input_sf_asset_tag('my_asset_field', '') ?>
-    </form>
+    public function configure()
+    {
+      $this->widgetSchema['asset_id'] = new sfWidgetFormAssetInput();
+      // usually you don't need to define validator, it should be already 
defined in generated form
+      $this->validatorSchema['asset_id'] = new sfValidatorPropelChoice('model' 
=> 'sfAsset');
+    }
 
+If not in admin generator, remember to use `use_javascripts_for_form($form)` 
in your form's template.
+
 This input is not a real file input tag, meaning that the chosen asset file 
will not
 be posted with the request. Instead, the action will be able to retrieve the 
asset
 file path relative to the web root, exactly what is needed to display it. 
Incidentally,
@@ -269,48 +279,4 @@
 * 100% model coverage for unit tests
 * Make thumbnails for PDF files (if ImageMagick is installed)
 * Drag and drop manipulation for file and folders
-* Screencast to show installation and usage
-
-Changelog
----------
-
-### 2009-05-14 | Trunk
-
-* ericbartels: Fixed image path on Windows systems
-* garak: Added Italian translation
-* garak: Fixed the `init_asset_library()` helper
-* jens schulze: Added German translation
-
-### 2009-04-20 | 0.9.3 Beta
-
-* francois: Removed unused method
-* francois: Fixed popup usage
-
-### 2009-04-20 | 0.9.2 Beta
-
-* francois: Fixed typo in folder details
-* francois: Implemented synchronize task
-
-### 2009-03-16 | 0.9.1 Beta
-
-* francois: 1.2 compatibility (WIP)
-* francois: Converted README to Markdown
-* francois: Fixed wrong exception parameter
-* francois: Fixed untranslated exception messages
-
-### 2008-06-23 | 0.8.2 Beta
-
-* francois: Fixed missing layout file in package
-* francois: Fixed layout inclusion in Windows
-
-### 2008-06-12 | 0.8.1 Beta
-
-* francois: Fixed initialization task
-* francois: Translated remaining strings
-* francois: Fixed helper declaration problems
-* francois: Added mass upload
-* francois: Fixed popup layout
-
-### 2008-06-11 | 0.8.0 Beta
-
-* wgarcia, blacksun, francois: Initial version
+* Screencast to show installation and usage
\ No newline at end of file

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php     
2010-05-24 15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php     
2010-05-24 16:01:06 UTC (rev 29606)
@@ -5,19 +5,19 @@
 function auto_wrap_text($text)
 {
   return preg_replace('/([_\-\.])/', '<span class="wrap_space"> </span>$1<span 
class="wrap_space"> </span>', $text);
-  return wordwrap($text, 2, '<span class="wrap_space"> </span>', true);
+  //return wordwrap($text, 2, '<span class="wrap_space"> </span>', true);
 }
 
 /**
  * Gives an image tag for an asset
  *
- * @param sfAsset $asset
- * @param string $thumbnail_type
- * @param array $options
- * @param  string  $relative_path
+ * @param  sfAsset $asset
+ * @param  string  $thumbType
+ * @param  array   $options
+ * @param  string  $relativePath
  * @return string
  */
-function asset_image_tag($asset, $thumbnail_type = 'full', $options = array(), 
$relative_path = null)
+function asset_image_tag($asset, $thumbType = 'full', $options = array(), 
$relativePath = null)
 {
   $options = array_merge(array(
     'alt'   => $asset->getDescription() . ' ' . $asset->getCopyright(),
@@ -26,17 +26,17 @@
 
   if ($asset->isImage())
   {
-    $src = $asset->getUrl($thumbnail_type, $relative_path);
+    $src = $asset->getUrl($thumbType, $relativePath);
   }
   else
   {
-    if ($thumbnail_type == 'full')
+    if ($thumbType == 'full')
     {
       throw new sfAssetException('Impossible to render a non-image asset in an 
image tag');
     }
     else
     {
-      switch($asset->getType())
+      switch ($asset->getType())
       {
         case 'txt':
           $src = '/sfAssetsLibraryPlugin/images/txt.png';
@@ -72,6 +72,11 @@
   return str_replace('%2F', '/', link_to($text, $path, $options));
 }
 
+/**
+ * @param  string  $text
+ * @param  sfAsset $asset
+ * @return string
+ */
 function link_to_asset_action($text, $asset)
 {
   $user = sfContext::getInstance()->getUser();
@@ -81,43 +86,68 @@
     {
       case 1:
         // popup called from a Rich Text Editor (ex: TinyMCE)
-        return link_to($text, 
"@sf_asset_library_tiny_config?id=".$asset->getId(), 
'title='.$asset->getFilename());
+        #return link_to($text, '@sf_asset_library_tiny_config?id=' . 
$asset->getId(), 'title=' . $asset->getFilename());
+        throw new sfAssetException('this option should be unused...');
       case 2:
         // popup called from a simple form input (or via input_sf_asset_tag)
-        return link_to_function($text, 
"setImageField('".$asset->getUrl()."',".$asset->getId().")");
+        return link_to_function($text, "setImageField('" . $asset->getUrl() . 
"','" . $asset->getUrl('small') . "'," . $asset->getId() . ')');
     }
   }
   else
   {
     // case : sf view (i.e. module sfAsset, view list)
-    return link_to($text, '@sf_asset_library_edit?id='.$asset->getId(), 
'title='.$asset->getFilename());
+    return link_to($text, '@sf_asset_library_edit?id=' . $asset->getId(), 
'title=' . $asset->getFilename());
   }
 }
 
+/**
+ * init asset library for use with TinyMCE
+ */
 function init_asset_library()
 {
-  use_helper('JavascriptBase');
+  
sfContext::getInstance()->getEventDispatcher()->connect('response.filter_content',
 'insert_asset_popup_url');
   use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
-
-  echo javascript_tag('sfAssetsLibrary.init(\'' . 
url_for('@sf_asset_library_list?popup=2') . '\')');
 }
 
-function init_assets_library_popup()
+/**
+ * called just before content is sent
+ * @see init_asset_library()
+ * @param  sfEvent $event
+ * @return string
+ */
+function insert_asset_popup_url(sfEvent $event)
 {
-  use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
+  $div = '<div id="sf_asset_js_url" style="display:none">' . 
url_for('@sf_asset_library_list?popup=2') . '</div>';
+  $content = $event->getSubject()->getContent();
+  $body = strpos($content, '</body>');
+  if (false !== $body)
+  {
+    $content = substr($content, 0, $body) . PHP_EOL . $div . PHP_EOL . 
substr($content, $body);
+  }
+  if (sfConfig::get('sf_web_debug'))
+  {
+    // TODO web debug toolbar is not displayed anymore :-|
+  }
 
-  return javascript_tag('sfAssetsLibrary.init(\'' . 
url_for('@sf_asset_library_list?popup=2') . '\')');
+  return $content;
 }
 
+/**
+ * get breadcrumbs
+ * @param  string  $path
+ * @param  boolean $linkLast
+ * @param  string  $action
+ * @return string
+ */
 function assets_library_breadcrumb($path, $linkLast = false, $action = '')
 {
   $action = $action ? $action : 
sfContext::getInstance()->getRequest()->getParameter('action');
-  if ($action == "edit")
+  if ($action == 'edit' || $action == 'update')
   {
-    $action = "list";
+    $action = 'list';
   }
   $html = '';
-  $breadcrumb = explode("/" , $path);
+  $breadcrumb = explode('/', $path);
   $nb_dirs = count($breadcrumb);
   $current_dir = '';
   $i = 0;
@@ -130,53 +160,18 @@
     else
     {
       $current_dir .= $i ? '/' . $dir : $dir;
-      // TODO check $action for camelCase
-      $html .= link_to_asset($dir, 
'@sf_asset_library_'.$action.'?dir='.$current_dir) .'<span 
class="crumb">/</span>';
+      $html .= link_to_asset($dir, '@sf_asset_library_' . $action . '?dir=' . 
$current_dir) . '<span class="crumb">/</span>';
     }
-    $i++;
+    $i ++;
   }
+
   return $html;
 }
 
 function input_sf_asset_image_tag($name, $options = array())
 {
-  use_helper('I18N');
-  use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
-  $options = _convert_options($options);
-  $type = 'all';
-  if (isset($options['images_only']))
-  {
-    $type = 'image';
-    unset($options['images_only']);
-  }
-  if (!isset($options['id']))
-  {
-    $options['id'] = get_id_from_name($name);
-  }
-
-  $formName = 'this.previousSibling.previousSibling.form.name';
-  if (isset($options['form_name']))
-  {
-    $formName = "'" . $options['form_name'] . "'";
-    unset($options['form_name']);
-  }
-
-  // The popup should open in the currently selected subdirectory
-  $html  = '&nbsp;';
-  $html .= image_tag('/sfAssetsLibraryPlugin/images/folder_open', array(
-    'alt' => __('Insert Image'),
-    'style' => 'cursor: pointer; vertical-align: middle',
-    'onclick' => "
-      initialDir = document.getElementById('" . $options['id'] . 
"').value.replace(/\/[^\/]*$/, '');
-      if (!initialDir) initialDir = '" . 
sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . "';
-      sfAssetsLibrary.openWindow({
-        form_name: " . $formName . ",
-        field_name: '" . $name . "',
-        type: '" . $type . "',
-        url: '" . url_for('@sf_asset_library_list?dir=PLACEHOLDER&popup=2') . 
"'.replace('PLACEHOLDER', initialDir),
-        scrollbars: 'yes'
-      });"
-  ));
-
-  return $html;
-}
+  $dir = sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media');
+  return '<a id="sf_asset_input_image" href="#" rel="{url: \'' . 
url_for('@sf_asset_library_list?dir=' . $dir . '&popup=2') . '\', name: \'' . 
$name . '\', type: \'' . $options['type'] . '\'}">' .
+    image_tag('/sfAssetsLibraryPlugin/images/folder_open', array('alt' => 
'Insert Image')) . '</a>' .
+    asset_image_tag(new sfAsset, 'small', array('id' => $options['id'] . 
'_img'));
+}
\ No newline at end of file

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php   
2010-05-24 15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php   
2010-05-24 16:01:06 UTC (rev 29606)
@@ -20,7 +20,7 @@
     // prepend our routes
 
     $idActions = array(
-      'tiny_config'   => 'tinyConfigMedia',
+     #'tiny_config'   => 'tinyConfigMedia',
       'delete_folder' => 'deleteFolder',
       'delete_asset'  => 'deleteAsset',
       'edit'          => 'edit',

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/widget/sfWidgetFormAssetInput.class.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/widget/sfWidgetFormAssetInput.class.php
      2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/widget/sfWidgetFormAssetInput.class.php
      2010-05-24 16:01:06 UTC (rev 29606)
@@ -7,7 +7,7 @@
  * @subpackage widget
  * @author     Massimiliano Arione <[email protected]>
  */
-class sfWidgetFormAssetInput extends sfWidgetFormInput
+class sfWidgetFormAssetInput extends sfWidgetFormInputHidden
 {
   /**
    * Constructor.
@@ -15,7 +15,6 @@
    * Available options:
    *
    *  * asset_type: The asset type ('all' for all types)
-   *  * form_name: The form name (javascript based by default)
    *
    * @param array $options     An array of options
    * @param array $attributes  An array of default HTML attributes
@@ -40,21 +39,14 @@
    */
   public function render($name, $value = null, $attributes = array(), $errors 
= array())
   {
-    return parent::render($name, $value, $attributes, $errors) . '&nbsp;' .
-      image_tag('/sfAssetsLibraryPlugin/images/folder_open', array(
-        'alt' => __('Insert Image'),
-        'style' => 'cursor: pointer; vertical-align: middle',
-        'onclick' => "
-          initialDir = 
document.getElementById('".$this->generateId($name)."').value.replace(/\/[^\/]*$/,
 '');
-          if (!initialDir) initialDir = 
'".sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')."';
-          sfAssetsLibrary.openWindow({
-            form_name: ".$this->getOption('form_name').",
-            field_name: '".$name."',
-            type: '".$this->getOption('asset_type')."',
-            url: 
'".url_for('@sf_asset_library_list?dir=PLACEHOLDER')."?popup=2'.replace('PLACEHOLDER',
 initialDir),
-            scrollbars: 'yes'
-          });"
-      ));
+    sfProjectConfiguration::getActive()->loadHelpers('sfAsset');
+    init_asset_library();
+
+    $html = parent::render($name, $value, $attributes, $errors) . '&nbsp;';
+    $attributes = $this->fixFormId(array('name' => $name));
+    $html .= input_sf_asset_image_tag($name, array('id' => $attributes['id'], 
'type' => $this->getOption('asset_type')));
+
+    return $html;
   }
 
   /**

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
 2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
 2010-05-24 16:01:06 UTC (rev 29606)
@@ -444,7 +444,7 @@
 
   /**
    * @param sfWebRequest $request
-   */
+   *
   public function executeTinyConfigMedia(sfWebRequest $request)
   {
     $this->forward404Unless($this->hasRequestParameter('id'), 'missing id');
@@ -452,7 +452,7 @@
     $this->forward404Unless($this->sfAsset, 'asset not found');
     $this->form = new sfAssetTinyConfigMediaForm($this->sfAsset);
     
$this->setLayout($this->getContext()->getConfiguration()->getTemplateDir('sfAsset',
 'popupLayout.php') . DIRECTORY_SEPARATOR . 'popupLayout');
-  }
+  }*/
 
   /**
    * @param string  $path
@@ -501,7 +501,7 @@
       
$this->setLayout($this->getContext()->getConfiguration()->getTemplateDir('sfAsset',
 'popupLayout.php') . DIRECTORY_SEPARATOR . 'popupLayout');
       $this->popup = true;
       // tinyMCE?
-      if (strpos($this->getUser()->getAttribute('popup', null, 
'sf_admin/sf_asset/navigation'), 'tiny') !== false)
+      if ($request->getParameter('tiny') != null)
       {
         $this->getResponse()->addJavascript('tiny_mce/tiny_mce_popup');
       }

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_actions.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_actions.php
      2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_actions.php
      2010-05-24 16:01:06 UTC (rev 29606)
@@ -2,7 +2,7 @@
   <li class="sf_admin_action_list">
     <?php echo link_to(__('Back to the list', null, 'sfAsset'), 
'@sf_asset_library_list') ?>
   </li>
-  <li class="sf_admin_action_save">
-    <input type="submit" class="sf_admin_action_save" value="<?php echo 
__('Upload', null, 'sfAsset') ?>" />
+  <li>
+    <input type="submit" class="sf_admin_action_save" value="<?php echo 
__(empty($button) ? 'Save' : $button, null, 'sfAsset') ?>" />
   </li>
 </ul>

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_form.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_form.php
 2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_edit_form.php
 2010-05-24 16:01:06 UTC (rev 29606)
@@ -6,7 +6,7 @@
     <label for="sf_asset_filepath"><?php echo __('Path:', null, 'sfAsset') 
?></label>
     <div class="content">
     <?php if (!$sf_asset->isNew()): ?>
-      <?php echo assets_library_breadcrumb($sf_asset->getRelativePath(), 0);?>
+      <?php echo assets_library_breadcrumb($sf_asset->getRelativePath(), 0) ?>
     <?php endif ?>
     </div>
   </div>

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_edit.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_edit.php
      2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_edit.php
      2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,4 +1,5 @@
-<?php use_helper('JavascriptBase', 'sfAsset') ?>
+<?php use_javascript('/sfAssetsLibraryPlugin/js/util') ?>
+<?php use_helper('sfAsset') ?>
 
 <?php if (!$sf_asset->isNew()): ?>
 
@@ -13,7 +14,7 @@
   <div class="form-row">
     <label for="new_name">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/page_edit.png', 
'align=top alt="edit') ?>
-      <?php echo link_to_function(__('Rename', null, 'sfAsset'), 
'document.getElementById("input_new_name").style.display="block";document.getElementById("sf_asset_filename").focus()')
 ?>
+      <?php echo link_to(__('Rename', null, 'sfAsset'), 
'@sf_asset_library_edit?id=' . $sf_asset->getId(), array('class' => 'toggle', 
'rel' => '{ div: \'input_new_name\'}')) ?>
     </label>
     <div class="content" id="input_new_name" style="display:none">
       <?php echo $renameform['filename'] ?>
@@ -27,7 +28,7 @@
   <div class="form-row">
     <label for="move_folder">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/page_go.png', 
'alt=go align=top') ?>
-      <?php echo link_to_function(__('Move', null, 'sfAsset'), 
'document.getElementById("input_move_folder").style.display="block"') ?>
+      <?php echo link_to(__('Move', null, 'sfAsset'), 
'@sf_asset_library_edit?id=' . $sf_asset->getId(), array('class' => 'toggle', 
'rel' => '{ div: \'input_move_folder\'}')) ?>
     </label>
     <div class="content" id="input_move_folder" style="display:none">
       <?php echo $moveform['parent_folder'] ?>
@@ -41,7 +42,7 @@
   <div class="form-row">
     <label for="new_file">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/page_refresh.png', 
'alt=refresh align=top') ?>
-      <?php echo link_to_function(__('Replace', null, 'sfAsset'), 
'document.getElementById("input_new_file").style.display="block"') ?>
+      <?php echo link_to(__('Replace', null, 'sfAsset'), 
'@sf_asset_library_edit?id=' . $sf_asset->getId(), array('class' => 'toggle', 
'rel' => '{ div: \'input_new_file\'}')) ?>
     </label>
     <div class="content" id="input_new_file" style="display:none">
       <?php echo $replaceform['file']->render(array('size' => 10)) ?>

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_list.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_list.php
      2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_list.php
      2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,4 +1,5 @@
-<?php use_helper('JavascriptBase', 'sfAsset') ?>
+<?php use_javascript('/sfAssetsLibraryPlugin/js/util') ?>
+<?php use_helper('sfAsset') ?>
 
 <?php if ($folder->isRoot()): ?>
 <div class="form-row">
@@ -11,7 +12,7 @@
   <div class="form-row">
     <label for="new_file">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/image_add.png', 
'alt=add align=top') ?>
-      <?php echo link_to_function(__('Upload a file here', null, 'sfAsset'), 
'document.getElementById("input_new_file").style.display="block"') ?>
+      <?php echo link_to(__('Upload a file here', null, 'sfAsset'), 
'@sf_asset_library_add_quick', array('class' => 'toggle', 'rel' => '{ div: 
\'input_new_file\'}')) ?>
     </label>
     <div class="content" id="input_new_file" style="display:none">
       <?php echo $fileform['file'] ?>
@@ -25,7 +26,7 @@
   <div class="form-row">
     <label for="new_directory">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/folder_add.png', 
'alt=add align=top') ?>
-      <?php echo link_to_function(__('Add a subfolder', null, 'sfAsset'), 
'document.getElementById("input_new_directory").style.display="block"') ?>
+      <?php echo link_to(__('Add a subfolder', null, 'sfAsset'), 
'@sf_asset_library_create_folder', array('class' => 'toggle', 'rel' => '{ div: 
\'input_new_directory\'}')) ?>
     </label>
     <div class="content" id="input_new_directory" style="display:none">
       <?php echo $folderform['name'] ?>
@@ -40,7 +41,7 @@
   <div class="form-row">
     <label for="new_folder">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/folder_edit.png', 
'alt=edit align=top') ?>
-      <?php echo link_to_function(__('Rename folder', null, 'sfAsset'), 
'document.getElementById("input_new_name").style.display="block";document.getElementById("sf_asset_folder_name").focus()')
 ?>
+      <?php echo link_to(__('Rename folder', null, 'sfAsset'), 
'@sf_asset_library_rename_folder', array('class' => 'toggle', 'rel' => '{ div: 
\'input_new_name\'}')) ?>
     </label>
     <div class="content" id="input_new_name" style="display:none">
       <?php echo $renameform['name'] ?>
@@ -54,7 +55,7 @@
   <div class="form-row">
     <label for="move_folder">
       <?php echo image_tag('/sfAssetsLibraryPlugin/images/folder_go.png', 
'alt=go align=top') ?>
-      <?php echo link_to_function(__('Move folder', null, 'sfAsset'), 
'document.getElementById("input_move_folder").style.display="block"') ?>
+      <?php echo link_to(__('Move folder', null, 'sfAsset'), 
'@sf_asset_library_move_folder', array('class' => 'toggle', 'rel' => '{ div: 
\'input_move_folder\'}')) ?>
     </label>
     <div class="content" id="input_move_folder" style="display:none">
       <?php echo $moveform['parent_folder'] ?>

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_search.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_search.php
    2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_search.php
    2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,20 +1,18 @@
-<?php use_helper('JavascriptBase') ?>
 <div class="form-row">
   <?php echo image_tag('/sfAssetsLibraryPlugin/images/magnifier.png', 
'alt=search align=top') ?>
-  <?php echo link_to_function(
-    __('Search', null, 'sfAsset'),
-    'document.getElementById("sf_asset_search").style.display="block"'
-  ) ?>
+  <?php echo link_to(__('Search', null, 'sfAsset'), 
'@sf_asset_library_search', array('class' => 'toggle', 'rel' => '{ div: 
\'sf_asset_search_form\'}')) ?>
 </div>
 
-<form action="<?php echo url_for('@sf_asset_library_search') ?>" method="get" 
id="sf_asset_search" style="display:none">
+<div id="sf_asset_search_form" style="display:none">
+  <form action="<?php echo url_for('@sf_asset_library_search') ?>" 
method="get" id="sf_asset_search">
 
-  <?php echo $form ?>
+    <?php echo $form ?>
 
-  <ul class="sf_admin_actions">
-    <li class="sf_admin_action_save">
-      <input type="submit" value="<?php echo __('Search', null, 'sfAsset') ?>" 
name="search" class="sf_admin_action_filter" />
-    </li>
-  </ul>
+    <ul class="sf_admin_actions">
+      <li>
+        <input type="submit" value="<?php echo __('Search', null, 'sfAsset') 
?>" name="search" class="sf_admin_action_filter" />
+      </li>
+    </ul>
 
-</form>
\ No newline at end of file
+  </form>
+</div>
\ No newline at end of file

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_sort.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_sort.php
      2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/_sidebar_sort.php
      2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,14 +1,11 @@
 <?php use_helper('sfAsset') ?>
 <div class="form-row">
-  <?php $sort = $sf_user->getAttribute('sort', 'name', 
'sf_admin/sf_asset/sort') ?>
-  <label>
-    <?php echo image_tag('/sfAssetsLibraryPlugin/images/text_linespacing.png', 
'alt=sort align=top') ?>
-    <?php if ($sort == 'name'): ?>
-      <?php echo __('Sorted by name', null, 'sfAsset') ?>
-      <?php echo link_to_asset(__('Sort by date', null, 'sfAsset'), 
'@sf_asset_library_' . $sf_params->get('action') . '?dir=' . 
$sf_params->get('dir') . '&sort=date') ?>
-    <?php else: ?>
-      <?php echo __('Sorted by date', null, 'sfAsset') ?>
-      <?php echo link_to_asset(__('Sort by name', null, 'sfAsset'), 
'@sf_asset_library_' . $sf_params->get('action').'?dir=' . 
$sf_params->get('dir'). '&sort=name') ?>
-    <?php endif ?>
-  </label>
+  <?php echo image_tag('/sfAssetsLibraryPlugin/images/text_linespacing.png', 
'alt=sort align=top') ?>
+  <?php if ($sf_user->getAttribute('sort', 'name', 'sf_admin/sf_asset/sort') 
== 'name'): ?>
+    <?php echo __('Sorted by name', null, 'sfAsset') ?>
+    <?php echo link_to_asset(__('Sort by date', null, 'sfAsset'), 
'@sf_asset_library_' . $sf_params->get('action') . '?dir=' . 
$sf_params->get('dir') . '&sort=date') ?>
+  <?php else: ?>
+    <?php echo __('Sorted by date', null, 'sfAsset') ?>
+    <?php echo link_to_asset(__('Sort by name', null, 'sfAsset'), 
'@sf_asset_library_' . $sf_params->get('action').'?dir=' . 
$sf_params->get('dir'). '&sort=name') ?>
+  <?php endif ?>
 </div>
\ No newline at end of file

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/massUploadSuccess.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/massUploadSuccess.php
  2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/massUploadSuccess.php
  2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,18 +1,23 @@
 <?php use_helper('I18N') ?>
 
-<h1><?php echo __('Mass upload files', null, 'sfAsset') ?></h1>
+<div id="sf_asset_container">
 
-<?php include_partial('sfAsset/create_folder_header') ?>
+  <h1><?php echo __('Mass upload files', null, 'sfAsset') ?></h1>
 
-<form action="<?php echo url_for('@sf_asset_library_mass_upload') ?>" 
method="post" enctype="multipart/form-data">
+  <?php include_partial('sfAsset/create_folder_header') ?>
 
-  <?php echo $form->renderGlobalErrors() ?>
 
-  <fieldset>
-  <?php echo $form ?>
-  </fieldset>
-  <?php include_partial('edit_actions') ?>
+  <form action="<?php echo url_for('@sf_asset_library_mass_upload') ?>" 
method="post" enctype="multipart/form-data">
 
-</form>
+    <?php echo $form->renderGlobalErrors() ?>
 
-<?php include_partial('sfAsset/create_folder_footer') ?>
+    <fieldset>
+    <?php echo $form ?>
+    </fieldset>
+    <?php include_partial('edit_actions', array('button' => 'Upload')) ?>
+
+  </form>
+
+  <?php include_partial('sfAsset/create_folder_footer') ?>
+
+</div>
\ No newline at end of file

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/tinyConfigMediaSuccess.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/tinyConfigMediaSuccess.php
     2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/templates/tinyConfigMediaSuccess.php
     2010-05-24 16:01:06 UTC (rev 29606)
@@ -1,3 +1,4 @@
+<?php throw new sfAssetException('should be unused...') ?>
 <?php use_helper('JavascriptBase', 'I18N', 'sfAsset') ?>
 <p><?php echo button_to_function(__('Back to the list', null, 'sfAsset'), 
'history.back()') ?></p>
 
@@ -12,7 +13,7 @@
       <div class=""><?php echo $sfAsset->getUrl() ?></div>
     </div>
 
-    <?php echo $form /* TODO add javascript events */ ?>
+    <?php echo $form ?>
 
     </fieldset>
 

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/data/fixtures/02_assets.yml
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/test/data/fixtures/02_assets.yml 
2010-05-24 15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/test/data/fixtures/02_assets.yml 
2010-05-24 16:01:06 UTC (rev 29606)
@@ -5,12 +5,14 @@
     description: asset1.png
     type:        image
     filesize:    1
+    created_at:  '<?php echo strtotime('-1 day') ?>'
   asset2:
     folder_id:   media
     filename:    asset2
     description: asset2.png
     type:        image
     filesize:    1
+    created_at:  '<?php echo strtotime('-3 hours') ?>'
   asset3:
     folder_id:   media
     filename:    asset3

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
   2010-05-24 15:53:35 UTC (rev 29605)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
   2010-05-24 16:01:06 UTC (rev 29606)
@@ -25,8 +25,25 @@
     checkElement('div#sf_asset_container div.assetImage', 5)->
     checkElement('div#sf_asset_container div.assetImage 
img[src$="folder.png"]', 2)->
     checkElement('div#sf_asset_container div.assetImage 
img[src$="asset1.png"]', 1)->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(4)', 
'/asset1/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(5)', 
'/asset2/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(6)', 
'/asset3/')->
   end()->
 
+  info('sorting options')->
+  click('Sort by date')->
+  with('response')->begin()->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(4)', 
'/asset3/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(5)', 
'/asset2/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(6)', 
'/asset1/')->
+  end()->
+  click('Sort by name')->
+  with('response')->begin()->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(4)', 
'/asset1/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(5)', 
'/asset2/')->
+    checkElement('div#sf_asset_container div.assetImage:nth-child(6)', 
'/asset3/')->
+  end()->
+
   info('enter first subfolder')->
   click('a[href$="media/TESTsubdir1"]')->
   with('request')->begin()->
@@ -263,6 +280,9 @@
     isParameter('module', 'sfAsset')->
     isParameter('action', 'massUpload')->
   end()->
+  with('response')->begin()->
+    isValid(true)->
+  end()->
   click('Upload', array('sf_asset' => array(
     'folder_id' => $subdir1->getId(),
     'file_1'    => dirname(__FILE__) . '/../data/demo2.png',

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/web/css/media.css
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/web/css/media.css        
2010-05-24 15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/web/css/media.css        
2010-05-24 16:01:06 UTC (rev 29606)
@@ -243,9 +243,376 @@
   margin: 2px 0 5px 0;
 }
 
+
 #tinyMCE_insert_form img.thumb
 {
   position: absolute;
   right: 20px;
   top: 20px;
-}
\ No newline at end of file
+}
+
+ul.sf_admin_actions li.sf_admin_action_list
+{
+  padding-left: 23px !important;
+}
+
+#sf_asset_bar form ul
+{
+  list-style: none;
+}
+
+/*** from admin css ***/
+
+#sf_asset_container ul, #sf_asset_container ol, #sf_asset_container li, 
#sf_asset_container h1, #sf_asset_container h2, #sf_asset_container h3, 
#sf_asset_container h4, #sf_asset_container h5, #sf_asset_container h6, 
#sf_asset_container pre, #sf_asset_container form, #sf_asset_container body, 
#sf_asset_container html, #sf_asset_container p, #sf_asset_container 
blockquote, #sf_asset_container fieldset, #sf_asset_container input { margin: 
0; padding: 0; }
+#sf_asset_container a img,:link img,:visited img { border: none; }
+
+#sf_asset_container a:link, #sf_asset_container a:visited
+{
+  text-decoration: none;
+}
+
+#sf_asset_container a:hover
+{
+  text-decoration: underline;
+}
+
+#sf_asset_container td
+{
+  margin: 0;
+  padding: 20px;
+  font-family: Arial, sans-serif;
+  font-size: 11px;
+  background-color: #fff;
+}
+
+#sf_asset_container p
+{
+  margin-bottom: 5px;
+}
+
+#sf_asset_container #sf_admin_bar
+{
+  margin-top: 8px;
+  position: absolute;
+  right: 20px;
+  width: 250px;
+}
+
+#sf_asset_container #sf_admin_content
+{
+  margin-right: 270px;
+}
+
+#sf_asset_container h1
+{
+  margin: 8px 0;
+  padding: 3px;
+  padding-left: 0px;
+  color: #555;
+  font-family: "Trebuchet MS", Arial, Verdana, sans-serif;
+  font-size: 25px;
+}
+
+#sf_asset_container fieldset h2
+{
+  padding: 3px;
+  color: #333;
+  background-color: #ccf;
+  font-size: 11px;
+}
+
+#sf_asset_container input, #sf_asset_container textarea, #sf_asset_container 
select
+{
+  padding: 3px;
+  font-family: Arial, sans-serif;
+  font-size: 11px;
+  border: 1px solid #ddd;
+  vertical-align:middle;
+}
+
+#sf_asset_container label
+{
+  display: block;
+  padding: 0 1em 3px 0;
+  float: left;
+  text-align: left;
+  width: 8em;
+  color: #666;
+  font-weight: normal !important;
+}
+
+#sf_asset_container label.required
+{
+  color: #333 !important;
+  font-weight: bold !important;
+}
+
+#sf_asset_container .sf_admin_filters input[type="checkbox"] + label
+{
+  display: inline;
+  float: none;
+}
+
+#sf_asset_container .save-ok
+{
+  margin-bottom: 10px;
+  border: 1px solid #73B65A;
+}
+
+#sf_asset_container .save-ok h2
+{
+  margin: 0 !important;
+  padding: 5px 20px 5px 25px;
+  font-size: 11px;
+  color: #fff;
+  background: #73B65A url(/sfPropelPlugin/images/ok.png) no-repeat 5px 2px;
+}
+
+#sf_asset_container .form-row
+{
+  clear: both;
+  padding: 10px;
+  border-bottom: 1px solid #ddd;
+}
+
+#sf_asset_container .form-row .content
+{
+  padding-left: 9em;
+}
+
+#sf_asset_container .form-errors
+{
+  margin-bottom: 10px;
+  border: 1px solid #f33;
+  background-color: #ffc;
+}
+
+#sf_asset_container .form-errors h2
+{
+  padding: 5px 20px 5px 25px;
+  font-size: 11px;
+  color: #fff;
+  background: #f33 url(/sfPropelPlugin/images/error.png) no-repeat 5px 2px;
+}
+
+#sf_asset_container .form-errors dl
+{
+  padding: 5px;
+}
+
+#sf_asset_container .form-errors dt
+{
+  font-weight: bold;
+  float: left;
+  padding-right: 5px;
+}
+
+#sf_asset_container .form-errors dd
+{
+  margin: 0;
+}
+
+#sf_asset_container .form-error
+{
+  color: #f33;
+}
+
+#sf_asset_container .form-error input, #sf_asset_container .form-error select, 
#sf_asset_container .form-error textarea
+{
+  border: 1px solid #f33;
+}
+
+#sf_asset_container fieldset
+{
+  margin-bottom: 3px;
+  border: 1px solid #ddd;
+  border-bottom: 0px;
+  background-color: #fff;
+}
+
+#sf_asset_container fieldset.collapsed * { display:none; }
+#sf_asset_container fieldset.collapsed h2, #sf_asset_container 
fieldset.collapsed { display:block !important; }
+#sf_asset_container fieldset.collapsed .collapse-toggle { display: inline 
!important; }
+#sf_asset_container fieldset.collapse h2 a.collapse-toggle { color:#ffc; }
+#sf_asset_container fieldset.collapse h2 a.collapse-toggle:hover { 
text-decoration:underline; }
+
+#sf_asset_container .float-left
+{
+  float: left;
+}
+
+#sf_asset_container .float-right
+{
+  float: right;
+}
+
+#sf_asset_container ul.sf_admin_td_actions
+{
+  list-style-type: none;
+}
+
+#sf_asset_container ul.sf_admin_td_actions li
+{
+  list-style-type: none;
+  display: inline;
+}
+
+#sf_asset_container ul.sf_admin_actions
+{
+  margin: 10px 0;
+  list-style-type: none;
+  text-align: right;
+}
+
+#sf_asset_container ul.sf_admin_actions a
+{
+  color: #333;
+}
+
+#sf_asset_container ul.sf_admin_actions li
+{
+  list-style-type: none;
+  display: inline;
+}
+
+#sf_asset_container ul.sf_admin_actions input
+{
+  padding: 3px 3px 3px 20px;
+  color: #333;
+  font-size: 11px;
+  font-family: Arial, sans-serif;
+  border: 0px;
+  border-right: 4px solid #999;
+  background-color: #ffc;
+  cursor: hand;
+  cursor: pointer;
+}
+
+#sf_asset_container .sf_admin_action_create
+{
+  background: url(/sfPropelPlugin/images/add.png) no-repeat 3px 2px;
+  border-right: 4px solid #73B65A !important;
+}
+
+#sf_asset_container .sf_admin_action_save
+{
+  background: url(/sf/sf_admin/images/save.png) no-repeat 3px 2px;
+  border-right: 4px solid #73B65A !important;
+}
+
+#sf_asset_container .sf_admin_action_save_and_add
+{
+  background: url/sf/sf_admin/images/save.png) no-repeat 3px 2px;
+  border-right: 4px solid #73B65A !important;
+}
+
+#sf_asset_container .sf_admin_action_save_and_list
+{
+  background: url(/sf/sf_admin/images/save.png) no-repeat 3px 2px;
+  border-right: 4px solid #73B65A !important;
+}
+
+#sf_asset_container .sf_admin_action_delete
+{
+  background: url(/sfPropelPlugin/images/delete.png) no-repeat 3px 2px;
+  border-right: 4px solid #E75C58 !important;
+}
+
+#sf_asset_container .sf_admin_action_cancel
+{
+  background: url(/sfPropelPlugin/images/cancel.png) no-repeat 3px 2px;
+  border-right: 4px solid #E75C58 !important;
+}
+
+#sf_asset_container .sf_admin_action_filter
+{
+  background: url(/sfPropelPlugin/images/filter.png) no-repeat 3px 2px;
+  border-right: 4px solid #66f !important;
+}
+
+#sf_asset_container .sf_admin_action_reset_filter
+{
+  background: url(/sfPropelPlugin/images/reset.png) no-repeat 3px 2px;
+  border-right: 4px solid #E75C58 !important;
+}
+
+#sf_asset_container .sf_admin_action_list
+{
+  background: url(/sfPropelPlugin/images/list.png) no-repeat 3px 2px;
+  border-right: 4px solid #66f !important;
+}
+
+#sf_asset_container .sf_admin_default_action
+{
+  background-color: #fc6 !important;
+  font-weight: bold !important;
+}
+
+#sf_asset_container .sf_admin_list
+{
+  width: 100%;
+  border: 1px solid #ddd;
+  border-bottom: 0px;
+  border-right: 0px;
+}
+
+#sf_asset_container .sf_admin_list th
+{
+  padding: 2px;
+  background-color: #ccf;
+  text-align: left;
+}
+
+#sf_asset_container .sf_admin_list th a
+{
+  color: #333;
+}
+
+#sf_asset_container .sf_admin_list td
+{
+  padding: 3px;
+  border-bottom: 1px solid #ddd;
+  border-right: 1px solid #ddd;
+}
+
+#sf_asset_container .sf_admin_filters li
+{
+  list-style-type: none;
+}
+
+#sf_asset_container .sf_admin_row_0 td
+{
+
+}
+
+#sf_asset_container .sf_admin_row_1 td
+{
+  background-color: #eef;
+}
+
+#sf_asset_container .sf_admin_edit_help
+{
+  color: #aaa;
+}
+
+#sf_asset_container .mceEditor td
+{
+  padding: 0px;
+}
+
+#sf_asset_container select.sf_admin_multiple, #sf_asset_container 
select.sf_admin_multiple-selected
+{
+  width: 12em;
+}
+
+#sf_asset_container ul.sf_admin_checklist li
+{
+  list-style: none;
+  line-height: 1.5em;
+}
+
+#sf_asset_container ul.sf_admin_checklist li label
+{
+  display: inline;
+  float: none;
+}

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/main.js
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/main.js   2010-05-24 
15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/main.js   2010-05-24 
16:01:06 UTC (rev 29606)
@@ -6,8 +6,35 @@
     this.url = url;
   },
 
-  fileBrowserReturn : function (url, id)
+  load : function()
   {
+    var asset_url = document.getElementById('sf_asset_js_url');
+    if (asset_url)
+    {
+      var url = asset_url.firstChild.data
+      this.url = url;
+    }
+    var asset_input = document.getElementById('sf_asset_input_image');
+    if (asset_input)
+    {
+      eval('var rel = ' + asset_input.getAttribute('rel'));
+      var fname = asset_input.previousSibling.previousSibling.form.name;
+      sfAssetsLibrary.addEvent(asset_input, 'click', function(e) {
+        sfAssetsLibrary.openWindow({
+          form_name: fname,
+          field_name: rel.name,
+          type: rel.type,
+          url: rel.url,
+          scrollbars: 'yes'
+        });
+        sfAssetsLibrary.prevDef(e);
+        sfAssetsLibrary.stopProp(e);
+      }, false);
+    }
+  },
+
+  fileBrowserReturn : function (url, thumbUrl, id)
+  {
     if (this.isTinyMCE)
     {
       tinyMCE.setWindowArg('editor_id', this.fileBrowserWindowArg);
@@ -20,12 +47,12 @@
     var img = this.callerWin.document.getElementById(this.callerFieldName + 
'_img');
     if (img)
     {
-      img.src = url;
+      img.src = thumbUrl;
     }
   },
 
-  // tentativo di aggiunta multipla, non funziona perche' non si possono
-  // inserire elementi del dom in una finestra diversa da quella corrente :-|
+  // tried to do multiple adds.
+  // not working: can't add DOM elements in a window different from current 
one :-|
   fileBrowserAdd : function (url, id)
   {
     var ul = this.callerWin.document.getElementById('multiassets');
@@ -42,8 +69,19 @@
 
   fileBrowserCallBack : function (field_name, url, type, win)
   {
+    if (!this.url)
+    {
+      this.load();
+      if (!this.url)
+      {
+        alert('error in getting asset url');
+        return;
+      }
+    }
+
+    var params = type == 'image' ? 'images_only=1&tiny=1' : 'tiny=1';
     tinyMCE.activeEditor.windowManager.open({
-      file :      type == 'image' ? this.url + '/images_only/1/tiny' : 
this.url + '/tiny',
+      file :      sfAssetsLibrary.addParams(this.url, params),
       title:      'Assets',
       width :     550,
       height :    600,
@@ -80,7 +118,7 @@
     this.fileBrowserType = options['type'];
     url = this.url;
 
-    if (options['type'] == 'image') url += '/images_only/1';
+    if (options['type'] == 'image') url = sfAssetsLibrary.addParams(url, 
'images_only=1');
     if (!(width = parseInt(options['width']))) width = 1000;
     if (!(height = parseInt(options['height']))) height = 600;
 
@@ -107,7 +145,49 @@
     if (options['close_previous'] != "no") sfAssetsLibrary.lastWindow = win;
 
     win.focus();
+  },
+
+  addParams: function (url, params)
+  {
+    return url.indexOf('?') > 0 ? url + '&' + params : url + '?' + params;
+  },
+
+  // x-browser event listener
+  addEvent : function(el, eType, fn, uC)
+  {
+    if (el.addEventListener)
+    {
+      el.addEventListener(eType, fn, uC);
+      return true;
+    }
+    else if (el.attachEvent)
+    {
+      return el.attachEvent('on' + eType, fn);
+    }
+    else
+    {
+      el['on' + eType] = fn;
+    }
+  },
+
+  // x-browser stop propagation
+  stopProp : function(e)
+  {
+    if (e && e.stopPropogation) e.stopPropogation();
+    else if (window.event && window.event.cancelBubble)
+    window.event.cancelBubble = true;
+  },
+
+  // x-browser prevent default
+  prevDef : function(e)
+  {
+    if (e && e.preventDefault) e.preventDefault();
+    else if (window.event && window.event.returnValue)
+    window.eventReturnValue = false;
   }
+
 }
 
 var sfAssetsLibrary = new sfAssetsLibrary_Engine();
+
+window.onload = sfAssetsLibrary.load;
\ No newline at end of file

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/popup.js
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/popup.js  2010-05-24 
15:53:35 UTC (rev 29605)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/popup.js  2010-05-24 
16:01:06 UTC (rev 29606)
@@ -1,4 +1,4 @@
-function setImageField(url, id)
+function setImageField(url, thumbUrl, id)
 {
   var win = null;
   if (typeof tinyMCEPopup != 'undefined')
@@ -8,7 +8,7 @@
 
   if (win)
   {
-    if (tinyMCEPopup.getWindowArg("type") == 'image' && 
win.ImageDialog.showPreviewImage)
+    if (tinyMCEPopup.getWindowArg('type') == 'image' && 
win.ImageDialog.showPreviewImage)
     {
       win.ImageDialog.showPreviewImage(url);
     }
@@ -22,11 +22,12 @@
     {
       opener = window.opener;
     }
-    opener.sfAssetsLibrary.fileBrowserReturn(url, id);
+    opener.sfAssetsLibrary.fileBrowserReturn(url, thumbUrl, id);
     window.close();
   }
 }
 
+// XXX unused...
 function addImageField(url, id)
 {
   if (!opener)

Added: plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/util.js
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/util.js                   
        (rev 0)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/web/js/util.js   2010-05-24 
16:01:06 UTC (rev 29606)
@@ -0,0 +1,98 @@
+sfAssetUtil = {
+
+  load: function()
+  {
+    var links = sfAssetUtil.getElementsByClassName('toggle');
+    if (!links)
+    {
+      return;
+    }
+    for (var i = 0; i < links.length; i ++)
+    {
+      sfAssetUtil.addEvent(links[i], 'click', function(e) {
+        sfAssetUtil.toggle(e);
+        sfAssetUtil.prevDef(e);
+        sfAssetUtil.stopProp(e);
+      }, false);
+    }
+  },
+
+  toggle: function(e)
+  {
+    var link = sfAssetUtil.getTarget(e);
+    eval('var rel = ' + link.getAttribute('rel'));
+    var div = document.getElementById(rel.div);
+    if (div)
+    {
+      if (div.style.display != 'none' )
+      {
+        div.style.display = 'none';
+      }
+      else
+      {
+        div.style.display = '';
+      }
+    }
+  },
+
+  getElementsByClassName: function(cl)
+  {
+    var retnode = [];
+    var myclass = new RegExp('\\b'+cl+'\\b');
+    var elem = document.getElementsByTagName('*');
+    for (var i = 0; i < elem.length; i++)
+    {
+      var classes = elem[i].className;
+      if (myclass.test(classes)) retnode.push(elem[i]);
+    }
+    return retnode;
+  },
+
+  // x-browser event listener
+  addEvent : function(el, eType, fn, uC)
+  {
+    if (el.addEventListener)
+    {
+      el.addEventListener(eType, fn, uC);
+      return true;
+    }
+    else if (el.attachEvent)
+    {
+      return el.attachEvent('on' + eType, fn);
+    }
+    else
+    {
+      el['on' + eType] = fn;
+    }
+  },
+
+  getTarget: function(e)
+  {
+    var targ;
+    if (e.target) targ = e.target;
+    else if (e.srcElement) targ = e.srcElement;
+    if (targ.nodeType == 3) // defeat Safari bug
+      targ = targ.parentNode;
+
+    return targ;
+  },
+
+  // x-browser stop propagation
+  stopProp : function(e)
+  {
+    if (e && e.stopPropogation) e.stopPropogation();
+    else if (window.event && window.event.cancelBubble)
+    window.event.cancelBubble = true;
+  },
+
+  // x-browser prevent default
+  prevDef : function(e)
+  {
+    if (e && e.preventDefault) e.preventDefault();
+    else if (window.event && window.event.returnValue)
+    window.eventReturnValue = false;
+  }
+
+}
+
+window.onload = sfAssetUtil.load;
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to