http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88718

Revision: 88718
Author:   yaron
Date:     2011-05-24 13:55:02 +0000 (Tue, 24 May 2011)
Log Message:
-----------
Added toggling of "Allowed values" field, so only certain property types would 
display that field

Modified Paths:
--------------
    trunk/extensions/SemanticForms/specials/SF_CreateProperty.php

Modified: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
===================================================================
--- trunk/extensions/SemanticForms/specials/SF_CreateProperty.php       
2011-05-24 11:54:26 UTC (rev 88717)
+++ trunk/extensions/SemanticForms/specials/SF_CreateProperty.php       
2011-05-24 13:55:02 UTC (rev 88718)
@@ -106,6 +106,20 @@
        }
 }
 
+function toggleAllowedValues(property_type) {
+       var allowed_values_div = document.getElementById("allowed_values");
+       // Page, String, Number, Email - is that a reasonable set of types
+       // for which enumerations should be allowed?
+       if (property_type == '{$datatype_labels['_wpg']}' ||
+               property_type == '{$datatype_labels['_str']}' ||
+               property_type == '{$datatype_labels['_num']}' ||
+               property_type == '{$datatype_labels['_ema']}') {
+               allowed_values_div.style.display = "";
+       } else {
+               allowed_values_div.style.display = "none";
+       }
+}
+
 END;
 
                // set 'title' as hidden field, in case there's no URL niceness
@@ -125,7 +139,7 @@
                foreach ( $datatype_labels as $label ) {
                        $select_body .= "       " . Xml::element( 'option', 
null, $label ) . "\n";
                }
-               $text .= Xml::tags( 'select', array( 'id' => 
'property_dropdown', 'name' => 'property_type', 'onChange' => 
'toggleDefaultForm(this.value);' ), $select_body ) . "\n";
+               $text .= Xml::tags( 'select', array( 'id' => 
'property_dropdown', 'name' => 'property_type', 'onChange' => 
'toggleDefaultForm(this.value); toggleAllowedValues(this.value);' ), 
$select_body ) . "\n";
 
                $default_form_input = wfMsg( 'sf_createproperty_linktoform' );
                $values_input = wfMsg( 'sf_createproperty_allowedvalsinput' );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to