16
16
( function ( $ , undefined ) {
17
17
18
18
var editableClass = "ui-editable ui-widget" ,
19
- formClass = "ui-editable-form " ,
19
+ editAreaClass = "ui-editable-edit-area " ,
20
20
buttonClass = "ui-editable-button" ,
21
21
buttonsAreaClass = "ui-editable-buttons-area" ,
22
22
cancelClass = "ui-editable-cancel" ,
@@ -49,7 +49,7 @@ $.widget( "ui.editable", {
49
49
} ,
50
50
51
51
save : function ( ) {
52
- $ ( "form" , this . element ) . submit ( ) ;
52
+ this . _save ( ) ;
53
53
} ,
54
54
55
55
cancel : function ( ) {
@@ -105,7 +105,7 @@ $.widget( "ui.editable", {
105
105
106
106
if ( ! this . _editing ) { }
107
107
else if ( $this . hasClass ( saveClass ) || $this . parent ( ) . hasClass ( saveClass ) ) {
108
- this . save ( ) ;
108
+ this . _save ( ) ;
109
109
return false ;
110
110
}
111
111
else if ( $this . hasClass ( cancelClass ) || $this . parent ( ) . hasClass ( cancelClass ) ) {
@@ -128,7 +128,7 @@ $.widget( "ui.editable", {
128
128
if ( this . _skipEnterSubmit ) {
129
129
break ;
130
130
}
131
- this . save ( ) ;
131
+ this . _save ( ) ;
132
132
return false ;
133
133
case keyCode . ESCAPE :
134
134
this . _cancel ( ) ;
@@ -159,9 +159,9 @@ $.widget( "ui.editable", {
159
159
// Create a new stacking context on element by setting its z-index from auto to 0.
160
160
this . element . css ( "z-index" , 0 ) ;
161
161
}
162
- this . element . html ( this . _form ( ) ) ;
162
+ this . element . html ( this . _drawEdit ( ) ) ;
163
+ this . _editor . bind ( this ) ;
163
164
this . _adjustInputWidth ( ) ;
164
- this . _formEvents ( ) ;
165
165
} ,
166
166
167
167
_placeholder : function ( ) {
@@ -170,21 +170,21 @@ $.widget( "ui.editable", {
170
170
. html ( this . options . placeholder ) ;
171
171
} ,
172
172
173
- _form : function ( ) {
174
- var form = $ ( "<form ></form >" ) . addClass ( formClass ) ;
175
- this . frame = form ;
173
+ _drawEdit : function ( ) {
174
+ var editArea = $ ( "<div ></div >" ) . addClass ( editAreaClass ) ;
175
+ this . frame = editArea ;
176
176
this . _hoverable ( this . frame . addClass ( hoverableClass ) ) ;
177
177
$ ( "<div></div>" )
178
178
. addClass ( inputAreaClass )
179
179
. append ( this . _editor . element ( this ) )
180
- . appendTo ( form ) ;
180
+ . appendTo ( editArea ) ;
181
181
if ( this . options . buttons ) {
182
- this . _drawButtons ( ) . appendTo ( form ) ;
182
+ this . _drawButtons ( ) . appendTo ( editArea ) ;
183
183
}
184
- return form ;
184
+ return editArea ;
185
185
} ,
186
186
187
- _drawButtons : function ( form ) {
187
+ _drawButtons : function ( ) {
188
188
var i , buttons = { } , ordered_buttons = $ ( [ ] ) ,
189
189
buttonsArea = $ ( "<div></div>" ) . addClass ( buttonsAreaClass ) ;
190
190
for ( i in this . options . buttons ) {
@@ -242,26 +242,15 @@ $.widget( "ui.editable", {
242
242
$ ( "." + inputAreaClass , this . frame ) . css ( margin ) ;
243
243
} ,
244
244
245
- _formEvents : function ( ) {
246
- var self = this ;
247
- $ ( "form" , this . element )
248
- . submit ( function ( event ) {
249
- self . _save . call ( self , event , self . _editor . value ( self , this ) ) ;
250
- return false ;
251
- } ) ;
252
- this . _editor . bind ( this ) ;
253
- } ,
254
-
255
- _save : function ( event , newValue ) {
256
- var hash = {
257
- value : newValue
258
- } ;
245
+ _save : function ( ) {
246
+ var newValue = this . _editor . value ( this ) ,
247
+ hash = { value : newValue } ;
259
248
260
- if ( this . _trigger ( "save" , event , hash ) === false ) {
249
+ if ( this . _trigger ( "save" , null , hash ) === false ) {
261
250
return ;
262
251
}
263
252
if ( this . value ( ) !== newValue ) {
264
- if ( this . _trigger ( "change" , event , hash ) === false ) {
253
+ if ( this . _trigger ( "change" , null , hash ) === false ) {
265
254
return ;
266
255
}
267
256
this . value ( newValue ) ;
@@ -301,8 +290,8 @@ $.ui.editable.editors = {
301
290
} )
302
291
. focus ( ) ;
303
292
} ,
304
- value : function ( editable , form ) {
305
- return $ ( "input" , form ) . val ( ) ;
293
+ value : function ( editable ) {
294
+ return $ ( "input" , editable . element ) . val ( ) ;
306
295
}
307
296
} ,
308
297
textarea : {
@@ -324,8 +313,8 @@ $.ui.editable.editors = {
324
313
} )
325
314
. focus ( ) ;
326
315
} ,
327
- value : function ( editable , form ) {
328
- return $ ( "textarea" , form ) . val ( ) . replace ( / \r \n | \r | \n / g, "<br/>" ) ;
316
+ value : function ( editable ) {
317
+ return $ ( "textarea" , editable . element ) . val ( ) . replace ( / \r \n | \r | \n / g, "<br/>" ) ;
329
318
}
330
319
} ,
331
320
select : $ . noop ,
@@ -338,8 +327,8 @@ $.ui.editable.editors = {
338
327
$ ( "input" , editable . element ) . datepicker ( editable . _editorOptions ) ;
339
328
$ . ui . editable . editors . text . bind ( editable ) ;
340
329
} ,
341
- value : function ( editable , form ) {
342
- return $ . ui . editable . editors . text . value ( editable , form ) ;
330
+ value : function ( editable ) {
331
+ return $ . ui . editable . editors . text . value ( editable ) ;
343
332
}
344
333
}
345
334
} ;
0 commit comments