ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

jquery.jstree.buttons.js
Go to the documentation of this file.
1
6 if( !ultimix )
7 {
8 ultimix = {};
9 }
10
16 if( !ultimix.jstree )
17 {
18 ultimix.jstree = {};
19 }
20
30 ultimix.jstree.create_node_event_handler = function( e , Data )
31 {
32 var RootId = jQuery( Data.rslt.parent ).attr( 'id' ).replace( 'phtml_' , '' );
33
34 ultimix.ajax_gate.direct_controller(
35 {
36 'package_name' : 'category::category_controller' ,
37 'meta' : 'meta_create_category' ,
38 'category_action' : 'create_record' ,
39 'root_id' : RootId ,
40 'title' : Data.rslt.name ,
41 'category_name' : 'category_name'
42 } ,
43 {
44 'after_request' : function( Result )
45 {
46 /* parsing result */
47 eval( "Result = " + Result + ";" );
48 jQuery( Data.rslt.obj ).attr( 'id' , 'phtml_' + Result.id );
49 }
50 }
51 );
52 }
53
63 ultimix.jstree.rename_node_event_handler = function( e , Data )
64 {
65 var NodeId = jQuery( Data.rslt.obj ).attr( 'id' ).replace( 'phtml_' , '' );
66
67 ultimix.ajax_gate.direct_controller(
68 {
69 'package_name' : 'category::category_controller' ,
70 'meta' : 'meta_update_category' ,
71 'category_action' : 'update_category_title' ,
72 'category_id' : NodeId ,
73 'title' : Data.rslt.new_name
74 }
75 );
76 }
77
87 ultimix.jstree.remove_node_event_handler = function( e , Data )
88 {
89 for( var i = 0 ; i < Data.rslt.obj.length ; i++ )
90 {
91 var NodeId = jQuery( Data.rslt.obj[ i ] ).attr( 'id' ).replace( 'phtml_' , '' );
92
93 /*ultimix.ajax_gate.direct_controller(
94 {
95 'package_name' : 'category::category_controller' ,
96 'meta' : 'meta_delete_category' ,
97 'category_action' : 'delete_record' ,
98 'category_record_id' : NodeId
99 }
100 );*/
101 }
102 }
103
109 ultimix.jstree.create_item = function()
110 {
111 var Tree = jQuery.jstree._focused();
112 var Node = Tree.get_selected();
113
114 if( Node.length )
115 {
116 Tree.create( Node , 'last' , ultimix.get_string( 'tree_new_item' ) );
117 }
118 else
119 {
120 ultimix.std_dialogs.MessageBox(
121 ultimix.get_string( 'select_tree_node_first' ) , ultimix.get_string( 'Error' ) ,
122 ultimix.std_dialogs.MB_OK | ultimix.std_dialogs.MB_ICONERROR | ultimix.std_dialogs.MB_MODAL
123 );
124 }
125 }
126
132 ultimix.jstree.rename_item = function()
133 {
134 var Tree = jQuery.jstree._focused();
135 var Node = Tree.get_selected();
136
137 if( Node.length )
138 {
139 Tree.rename();
140 }
141 else
142 {
143 ultimix.std_dialogs.MessageBox(
144 ultimix.get_string( 'select_tree_node_first' ) , ultimix.get_string( 'Error' ) ,
145 ultimix.std_dialogs.MB_OK | ultimix.std_dialogs.MB_ICONERROR | ultimix.std_dialogs.MB_MODAL
146 );
147 }
148 }
149
157 ultimix.jstree.move_up_for_selected = function( Tree )
158 {
159 var SelectedNodes = Tree.get_selected();
160
161 for( var i = 0 ; i < SelectedNodes.length ; i++ )
162 {
163 var Children = Tree._get_children( SelectedNodes[ i ] );
164
165 if( Children.length )
166 {
167 Tree.move_node( Children , SelectedNodes[ i ] , 'after' );
168 }
169 }
170 }
171
179 ultimix.jstree.show_remove_item_dialog = function( ConfirmString )
180 {
181 if( ConfirmString == '' )
182 {
183 ConfirmString = 'shure_to_delete_tree_item';
184 }
185
186 ultimix.std_dialogs.MessageBox(
187 ultimix.get_string( ConfirmString ) ,
188 ultimix.get_string( 'Question' ) ,
189 ultimix.std_dialogs.MB_YESNO | ultimix.std_dialogs.MB_ICONQUESTION | ultimix.std_dialogs.MB_MODAL ,
190 function( Result )
191 {
192 if( Result == ultimix.std_dialogs.MB_YES )
193 {
194 var Tree = jQuery.jstree._focused();
195
196 ultimix.jstree.move_up_for_selected( Tree );
197
198 Tree.remove();
199 }
200 }
201 );
202 }
203
211 ultimix.jstree.remove_item = function( ConfirmString )
212 {
213 var Tree = jQuery.jstree._focused();
214 var Node = Tree.get_selected();
215 var ErrMsg = '';
216 if( jQuery( Node ).attr( 'rel' ) == 'root' )
217 {
218 ErrMsg = ultimix.get_string( 'cant_delete_root_node' );
219 }
220 if( Node.length == 0 )
221 {
222 ErrMsg = ultimix.get_string( 'select_tree_node_first' );
223 }
224 if( ErrMsg != '' )
225 {
226 ultimix.std_dialogs.MessageBox(
227 ErrMsg , ultimix.get_string( 'Error' ) ,
228 ultimix.std_dialogs.MB_OK | ultimix.std_dialogs.MB_ICONERROR | ultimix.std_dialogs.MB_MODAL
229 );
230 return;
231 }
232
233 ultimix.jstree.show_remove_item_dialog( ConfirmString );
234 }