Author: nicolas
Date: 2010-04-04 16:04:53 +0200 (Sun, 04 Apr 2010)
New Revision: 28973

Modified:
   plugins/sfDoctrineEditableComponentPlugin/trunk/README
   plugins/sfDoctrineEditableComponentPlugin/trunk/config/app.yml
   plugins/sfDoctrineEditableComponentPlugin/trunk/config/doctrine/schema.yml
   
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/lib/BasesfEditableComponentActions.class.php
   
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/cssSuccess.css.php
   
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/jsSuccess.js.php
Log:
[sfDoctrineEditableComponentPlugin] mostly javascript and UI usability 
enhancements

Modified: plugins/sfDoctrineEditableComponentPlugin/trunk/README
===================================================================
--- plugins/sfDoctrineEditableComponentPlugin/trunk/README      2010-04-04 
11:17:55 UTC (rev 28972)
+++ plugins/sfDoctrineEditableComponentPlugin/trunk/README      2010-04-04 
14:04:53 UTC (rev 28973)
@@ -3,9 +3,9 @@
 
 **WARNING:** This plugin is currently in an alpha state. Use with caution, 
feedback warmly welcome.
 
-This plugin allows to set up edit-in-place components (plain or html), 
typically to enable content administration directly from the a frontend 
application.
+This plugin allows to set up edit-in-place, i18n-ready components (plain or 
html), typically to enable simple contents administration directly from the a 
frontend application. For achieving this goal, it uses some cool javascript 
libs like jQuery, facebox, CKEditor and the Doctrine ORM for persistence.
 
-The plugin uses some cool javascript libs like jQuery, facebox, CKEditor and 
the Doctrine ORM for persistence.
+It's compatible with symfony 1.3 and 1.4.
 
 Installation
 ------------

Modified: plugins/sfDoctrineEditableComponentPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfDoctrineEditableComponentPlugin/trunk/config/app.yml      
2010-04-04 11:17:55 UTC (rev 28972)
+++ plugins/sfDoctrineEditableComponentPlugin/trunk/config/app.yml      
2010-04-04 14:04:53 UTC (rev 28973)
@@ -10,4 +10,5 @@
       stylesheets:
         - /facebox/facebox.css
     component_css_class_name:  sfEditableComponent
-    default_content:          'This is a placeholder. In editing mode, 
double-click me to edit.'
\ No newline at end of file
+    default_content:          'This is a placeholder. In editing mode, 
double-click me to edit.'
+    use_rich_editor:          true
\ No newline at end of file

Modified: 
plugins/sfDoctrineEditableComponentPlugin/trunk/config/doctrine/schema.yml
===================================================================
--- plugins/sfDoctrineEditableComponentPlugin/trunk/config/doctrine/schema.yml  
2010-04-04 11:17:55 UTC (rev 28972)
+++ plugins/sfDoctrineEditableComponentPlugin/trunk/config/doctrine/schema.yml  
2010-04-04 14:04:53 UTC (rev 28973)
@@ -13,8 +13,7 @@
       autoincrement: true
     name:
       type: string(255)
-      notblank: true
-      unique: true
+      notnull: true
     type:
       type: enum
       values:
@@ -26,5 +25,5 @@
       notnull: true
   indexes:
     unicity:
-      fields: [name, type] 
+      fields: [name] 
       type:   unique

Modified: 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/lib/BasesfEditableComponentActions.class.php
===================================================================
--- 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/lib/BasesfEditableComponentActions.class.php
    2010-04-04 11:17:55 UTC (rev 28972)
+++ 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/lib/BasesfEditableComponentActions.class.php
    2010-04-04 14:04:53 UTC (rev 28973)
@@ -23,6 +23,7 @@
 
   public function executeJs(sfWebRequest $request)
   {
+    $this->useRichEditor = 
sfConfig::get('app_sfDoctrineEditableComponentPlugin_use_rich_editor', false);
     
$this->forward404Unless($this->getUser()->hasCredential(sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential',
 'editable_content_admin')));
   }
 
@@ -46,7 +47,7 @@
 
     return $this->renderText(json_encode(array(
       'error'  => $error,
-      'result' => $component ? $component->getContent() : '',
+      'result' => isset($component) ? $component->getContent() : '',
     )));
   }
 

Modified: 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/cssSuccess.css.php
===================================================================
--- 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/cssSuccess.css.php
    2010-04-04 11:17:55 UTC (rev 28972)
+++ 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/cssSuccess.css.php
    2010-04-04 14:04:53 UTC (rev 28973)
@@ -20,10 +20,13 @@
 #sfEditableComponentForm {
 }
   #sfEditableComponentForm textarea {
-    width: 98%;
+    width: 600px;
     height: 120px;
+    margin-left: 20px;
   }
   #sfEditableComponentForm p {
+    padding: 0;
+    margin: 0;
     text-align: right;
   }
 

Modified: 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/jsSuccess.js.php
===================================================================
--- 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/jsSuccess.js.php
      2010-04-04 11:17:55 UTC (rev 28972)
+++ 
plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/templates/jsSuccess.js.php
      2010-04-04 14:04:53 UTC (rev 28973)
@@ -2,6 +2,7 @@
   // Configuration
   var getServiceUrl = '<?php echo url_for('@editable_component_service_get') 
?>';
   var updateServiceUrl = '<?php echo 
url_for('@editable_component_service_update') ?>';
+  var useRichEditor = <?php echo var_export($useRichEditor, true) ?>;
   var CKConfig = {
       toolbar  : 'Basic',
       language : '<?php echo $sf_user->getCulture() ?>',
@@ -20,17 +21,27 @@
       ]
     };
   
-  // Facebox settings
-  $.facebox.settings.opacity = 0.4;
-  $.facebox.settings.loadingImage = '<?php echo $pluginWebRoot 
?>/facebox/loading.gif';
-  $.facebox.settings.closeImage   = '<?php echo $pluginWebRoot 
?>/facebox/closelabel.gif';
-  $(this).bind('close.facebox', function() {
+  // Local methods
+  var cleanRichEditor = function() {
     // Removes every CKEditor opened instance
     if (CKEDITOR.instances['sfEditableComponentTextarea']) {
       CKEDITOR.remove(CKEDITOR.instances['sfEditableComponentTextarea']);
     }
-  });
+    return true;
+  };
   
+  var openRichEditor = function() {
+    cleanRichEditor();
+    CKEDITOR.replace('sfEditableComponentTextarea', CKConfig);
+    return true;
+  };
+  
+  // Facebox settings
+  $.facebox.settings.opacity = 0.4;
+  $.facebox.settings.loadingImage = '<?php echo $pluginWebRoot 
?>/facebox/loading.gif';
+  $.facebox.settings.closeImage   = '<?php echo $pluginWebRoot 
?>/facebox/closelabel.gif';
+  $(this).bind('close.facebox', cleanRichEditor);
+  
   // Components behaviors
   // Empty content check
   $('.<?php echo $componentCssClassName ?>').each(function(){
@@ -38,6 +49,7 @@
       $(this).html('<?php echo $defaultContent ?>');
     }
   });
+  
   // Link deactivation
   $('.<?php echo $componentCssClassName ?> a').click(function() {
     if (confirm('Open link in a new window?')) {
@@ -45,27 +57,49 @@
     }
     return false;
   });
+  
   // Editing mode trigger
   $('.<?php echo $componentCssClassName ?>').dblclick(function() {
     var component = $(this);
     var type = $(component).hasClass('plain') ? 'plain' : 'html';
     $.facebox(function(){
       $.get(getServiceUrl, function(result) {
-        $.facebox(
-        '<form action="' + updateServiceUrl + '" method="post" 
id="sfEditableComponentForm">'
-          + '<h2>Edit ' + $(component).attr('id') + '</h2>'
+        // Form
+        var tagName = $(component)[0].localName;
+        var tagInfo = [
+          '<div><code>&lt;' + tagName + '&gt;</code></div>',
+          '<div><code>&lt;/' + tagName + '&gt;</code></div>'
+        ];
+        var switchLink = '';
+        if (!useRichEditor) {
+          switchLink = '<a href="" id="sfEditableComponentSwitch">Switch to 
rich editor</a>&nbsp;'
+        }
+        var formHtml = '<form action="' + updateServiceUrl + '" method="post" 
id="sfEditableComponentForm">'
+          + '<h2>Edit ' + $(component).attr('id') + ' (' + type + ')</h2>'
+          + (!useRichEditor ? tagInfo[0] : '')
           + '<p><textarea name="value" id="sfEditableComponentTextarea">' + 
$(component).html().trim() + '</textarea></p>'
+          + (!useRichEditor ? tagInfo[1] : '')
           + '<input type="hidden" value="' + $(component).attr('id') + '" 
name="id" id="sfEditableComponentId"/>'
           + '<input type="hidden" value="' + type + '" name="type" 
id="sfEditableComponentType"/>'
-          + '<p><input type="submit" value="<?php echo __('Update') ?>"/></p>'
-        + '</form>'
-        );
-        if ('html' == type) {
-          CKEDITOR.replace('sfEditableComponentTextarea', CKConfig);
+          + '<p>' + switchLink + '<input type="submit" value="Update"/></p>'
+        + '</form>';
+        $.facebox(formHtml);
+        // Switch link
+        $('#sfEditableComponentSwitch').live('click', function(){
+          openRichEditor();
+          $(this).hide();
+          return false;
+        });
+        // Focus on textarea
+        $('#sfEditableComponentTextarea').focus().select();
+        // Rich editor
+        if (useRichEditor && 'html' == type) {
+          openRichEditor();
         }
       }, 'json');
     });
   });
+  
   // Component contents update form
   $('#sfEditableComponentForm').live('submit', function(data){
     var form = $(this);

-- 
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