Author: michkinn
Date: 2010-03-31 15:34:04 +0200 (Wed, 31 Mar 2010)
New Revision: 28919
Modified:
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/web/css/screen.css
Log:
Modified:
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
===================================================================
---
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
2010-03-31 12:33:52 UTC (rev 28918)
+++
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
2010-03-31 13:34:04 UTC (rev 28919)
@@ -1,11 +1,21 @@
<?php
- function get_nested_set_manager($model, $field, $root = 0){
+ function get_nested_set_manager($model, $field, $root = 0){
+
+ if ( !sfConfig::has('app_sfJqueryTree_withContextMenu') ){
+ sfConfig::set('app_sfJqueryTree_withContextMenu',true);
+ }
+
sfContext::getInstance()->getResponse()->addStylesheet('/sfJqueryTreeDoctrineManagerPlugin/jsTree/themes/default/style.css');
sfContext::getInstance()->getResponse()->addStylesheet('/sfJqueryTreeDoctrineManagerPlugin/css/screen.css');
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.js');
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.cookie.js');
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.tree.min.js');
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/plugins/jquery.tree.cookie.js');
+
+ if ( sfConfig::get('app_sfJqueryTree_withContextMenu') ){
+
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/plugins/jquery.tree.contextmenu.js');
+ }
+
return get_component('sfJqueryTreeDoctrineManager', 'manager',
array('model' => $model, 'field' => $field, 'root' => $root));
}
\ No newline at end of file
Modified:
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
===================================================================
---
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
2010-03-31 12:33:52 UTC (rev 28918)
+++
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
2010-03-31 13:34:04 UTC (rev 28919)
@@ -7,7 +7,7 @@
if($record['level'] > $prevLevel) echo '<ul>';
elseif ($record['level'] < $prevLevel) echo
str_repeat('</ul></li>', $prevLevel - $record['level']); ?>
<li id ="phtml_<?php echo $record->id ?>">
- <a href="#"><ins> </ins><?php echo $record->$field;?></a>
+ <a href="#"><ins> </ins><?php echo $record->$field;?></a>
<?php $prevLevel = $record['level'];
endforeach; ?>
</ul>
@@ -15,42 +15,74 @@
<?php endif;?>
<?php echo javascript_tag();?>
$(function () {
+
+
$("#<?php echo strtolower($model);?>-nested-set").tree({
plugins : {
- cookie : { prefix : "<?php echo
strtolower($model);?>_jstree_" }
+ cookie : { prefix : "<?php echo
strtolower($model);?>_jstree_" },
+ <?php if ( sfConfig::get('app_sfJqueryTree_withContextMenu') ): ?>
+ contextmenu : {
+ items : {
+ // get rid of the remove item
+ create : false,
+ rename : false,
+ remove : false,
+ // add an item of our own
+ edit : {
+ label : "<?php echo __('edit
object');?>",
+ icon :
"/sfDoctrinePlugin/images/edit.png", // you can set this to a classname or a
path to an icon like ./myimage.gif
+ visible : function (NODE,
TREE_OBJ) {
+ // this action will be
disabled if more than one node is selected
+ if(NODE.length != 1)
return 0;
+ // this action will not
be in the list if condition is met
+
if(TREE_OBJ.get_text(NODE) == "Child node 1") return -1;
+ // otherwise - OK
+ return 1;
+ },
+ action : function (NODE,
TREE_OBJ) {
+
document.location.href = '<?php echo strtolower($model);?>/' +
NODE.attr('id').replace('phtml_','') + '/edit';
+ },
+ separator_before : true
+ }
+ }
+ }
+
+ <?php endif; ?>
+
+
},
callback: {// activate add and delete node button
onchange: function(){
$('.nodeinteraction').attr('disabled','');},
onrename : function (NODE, TREE_OBJ, RB) {
- $('.error').remove();
- $('.notice').remove();
+ $('.error').remove();
+ $('.notice').remove();
$('.nested_set_manager_holder').before('<div
class="waiting"><?php echo __('Sending data to server.');?></div>');
- if (TREE_OBJ.get_text(NODE) == 'New folder'){
- $('.nested_set_manager_holder').before('<div
class="error">"'+TREE_OBJ.get_text(NODE)+'" <?php echo __('is not a valid
name');?></div>');
- $.tree.focused().rename();
- }
- else {
- if (NODE.id == ''){ // happen if creation of a new node
- $.ajax({
- type: "POST",
- url : '<?php echo
url_for('sfJqueryTreeDoctrineManager/Add_child');?>',
- dataType : 'json',
- data : 'root=<?php echo $root;?>&model=<?php echo
$model;?>&field=<?php echo
$field;?>&value='+TREE_OBJ.get_text(NODE)+'&parent_id=' +
TREE_OBJ.parent(NODE).attr('id').replace('phtml_',''),
- complete : function(){
-
$('.waiting').remove();
- },
- success : function
(data, textStatus) {
- $('.nested_set_manager_holder').before('<div
class="notice"><?php echo __('The item was created successfully.');?></div>');
-
$(NODE).attr('id','phtml_'+data.id);
- },
- error : function (data, textStatus) {
- $('.nested_set_manager_holder').before('<div
class="error"><?php echo __('Error while creating the item.');?></div>');
- $.tree.rollback(RB);
- }
- });
- }
+ if (TREE_OBJ.get_text(NODE) == 'New folder'){
+ $('.nested_set_manager_holder').before('<div
class="error">"'+TREE_OBJ.get_text(NODE)+'" <?php echo __('is not a valid
name');?></div>');
+ $.tree.focused().rename();
+ }
+ else {
+ if (NODE.id == ''){ // happen if creation of a new node
+ $.ajax({
+ type: "POST",
+ url : '<?php echo
url_for('sfJqueryTreeDoctrineManager/Add_child');?>',
+ dataType : 'json',
+ data : 'root=<?php echo $root;?>&model=<?php echo
$model;?>&field=<?php echo
$field;?>&value='+TREE_OBJ.get_text(NODE)+'&parent_id=' +
TREE_OBJ.parent(NODE).attr('id').replace('phtml_',''),
+ complete : function(){
+ $('.waiting').remove();
+ },
+ success : function (data, textStatus) {
+ $('.nested_set_manager_holder').before('<div
class="notice"><?php echo __('The item was created successfully.');?></div>');
+ $(NODE).attr('id','phtml_'+data.id);
+ },
+ error : function (data, textStatus) {
+ $('.nested_set_manager_holder').before('<div
class="error"><?php echo __('Error while creating the item.');?></div>');
+ $.tree.rollback(RB);
+ }
+ });
+ }
else { // happen when renaming an
existing node
$.ajax({
type: "POST",
Modified: plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/web/css/screen.css
===================================================================
--- plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/web/css/screen.css
2010-03-31 12:33:52 UTC (rev 28918)
+++ plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/web/css/screen.css
2010-03-31 13:34:04 UTC (rev 28919)
@@ -9,3 +9,6 @@
border-bottom: 1px solid #ddd;
background-color: #ffc;
}
+
+
+#jstree-contextmenu .edit ins {background-position : 0 0;}
\ 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.