Changeset View
Changeset View
Standalone View
Standalone View
core/script/kjs_field.cpp
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | |||||
219 | { | 219 | { | ||
220 | FormField *field = reinterpret_cast< FormField * >( object ); | 220 | FormField *field = reinterpret_cast< FormField * >( object ); | ||
221 | bool b = value.toBoolean( context ); | 221 | bool b = value.toBoolean( context ); | ||
222 | field->setVisible( !b ); | 222 | field->setVisible( !b ); | ||
223 | 223 | | |||
224 | updateField( field ); | 224 | updateField( field ); | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | // Field.display (getter) | ||||
228 | static KJSObject fieldGetDisplay( KJSContext *, void *object ) | ||||
229 | { | ||||
230 | const FormField *field = reinterpret_cast< FormField * >( object ); | ||||
231 | return KJSBoolean( field->isVisible() ); | ||||
232 | } | ||||
233 | | ||||
234 | // Field.display (setter) | ||||
235 | static void fieldSetDisplay( KJSContext *context, void *object, KJSObject value ) | ||||
236 | { | ||||
237 | FormField *field = reinterpret_cast< FormField * >( object ); | ||||
238 | bool b = value.toBoolean( context ); | ||||
239 | field->setVisible( b ); | ||||
240 | | ||||
241 | updateField( field ); | ||||
242 | } | ||||
243 | | ||||
244 | | ||||
227 | void JSField::initType( KJSContext *ctx ) | 245 | void JSField::initType( KJSContext *ctx ) | ||
228 | { | 246 | { | ||
229 | static bool initialized = false; | 247 | static bool initialized = false; | ||
230 | if ( initialized ) | 248 | if ( initialized ) | ||
231 | return; | 249 | return; | ||
232 | initialized = true; | 250 | initialized = true; | ||
233 | 251 | | |||
234 | if ( !g_fieldProto ) | 252 | if ( !g_fieldProto ) | ||
235 | g_fieldProto = new KJSPrototype(); | 253 | g_fieldProto = new KJSPrototype(); | ||
236 | 254 | | |||
237 | g_fieldProto->defineProperty( ctx, QStringLiteral("doc"), fieldGetDoc ); | 255 | g_fieldProto->defineProperty( ctx, QStringLiteral("doc"), fieldGetDoc ); | ||
238 | g_fieldProto->defineProperty( ctx, QStringLiteral("name"), fieldGetName ); | 256 | g_fieldProto->defineProperty( ctx, QStringLiteral("name"), fieldGetName ); | ||
239 | g_fieldProto->defineProperty( ctx, QStringLiteral("readonly"), | 257 | g_fieldProto->defineProperty( ctx, QStringLiteral("readonly"), | ||
240 | fieldGetReadOnly, fieldSetReadOnly ); | 258 | fieldGetReadOnly, fieldSetReadOnly ); | ||
241 | g_fieldProto->defineProperty( ctx, QStringLiteral("type"), fieldGetType ); | 259 | g_fieldProto->defineProperty( ctx, QStringLiteral("type"), fieldGetType ); | ||
242 | g_fieldProto->defineProperty( ctx, QStringLiteral("value"), fieldGetValue, fieldSetValue ); | 260 | g_fieldProto->defineProperty( ctx, QStringLiteral("value"), fieldGetValue, fieldSetValue ); | ||
243 | g_fieldProto->defineProperty( ctx, QStringLiteral("hidden"), fieldGetHidden, fieldSetHidden ); | 261 | g_fieldProto->defineProperty( ctx, QStringLiteral("hidden"), fieldGetHidden, fieldSetHidden ); | ||
262 | g_fieldProto->defineProperty( ctx, QStringLiteral("display"), fieldGetDisplay, fieldSetDisplay ); | ||||
244 | } | 263 | } | ||
245 | 264 | | |||
246 | KJSObject JSField::wrapField( KJSContext *ctx, FormField *field, Page *page ) | 265 | KJSObject JSField::wrapField( KJSContext *ctx, FormField *field, Page *page ) | ||
247 | { | 266 | { | ||
248 | // ### cache unique wrapper | 267 | // ### cache unique wrapper | ||
249 | KJSObject f = g_fieldProto->constructObject( ctx, field ); | 268 | KJSObject f = g_fieldProto->constructObject( ctx, field ); | ||
250 | f.setProperty( ctx, QStringLiteral("page"), page->number() ); | 269 | f.setProperty( ctx, QStringLiteral("page"), page->number() ); | ||
251 | g_fieldCache->insert( field, page ); | 270 | g_fieldCache->insert( field, page ); | ||
Show All 11 Lines |