+++ /dev/null
-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-/**\r
- * @file Forms Plugin\r
- */\r
-\r
-CKEDITOR.plugins.add( 'forms',\r
-{\r
- init : function( editor )\r
- {\r
- var lang = editor.lang;\r
-\r
- editor.addCss(\r
- 'form' +\r
- '{' +\r
- 'border: 1px dotted #FF0000;' +\r
- 'padding: 2px;' +\r
- '}\n' );\r
-\r
- editor.addCss(\r
- 'img.cke_hidden' +\r
- '{' +\r
- 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/hiddenfield.gif' ) + ');' +\r
- 'background-position: center center;' +\r
- 'background-repeat: no-repeat;' +\r
- 'border: 1px solid #a9a9a9;' +\r
- 'width: 16px !important;' +\r
- 'height: 16px !important;' +\r
- '}' );\r
-\r
- // All buttons use the same code to register. So, to avoid\r
- // duplications, let's use this tool function.\r
- var addButtonCommand = function( buttonName, commandName, dialogFile )\r
- {\r
- editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) );\r
-\r
- editor.ui.addButton( buttonName,\r
- {\r
- label : lang.common[ buttonName.charAt(0).toLowerCase() + buttonName.slice(1) ],\r
- command : commandName\r
- });\r
- CKEDITOR.dialog.add( commandName, dialogFile );\r
- };\r
-\r
- var dialogPath = this.path + 'dialogs/';\r
- addButtonCommand( 'Form', 'form', dialogPath + 'form.js' );\r
- addButtonCommand( 'Checkbox', 'checkbox', dialogPath + 'checkbox.js' );\r
- addButtonCommand( 'Radio', 'radio', dialogPath + 'radio.js' );\r
- addButtonCommand( 'TextField', 'textfield', dialogPath + 'textfield.js' );\r
- addButtonCommand( 'Textarea', 'textarea', dialogPath + 'textarea.js' );\r
- addButtonCommand( 'Select', 'select', dialogPath + 'select.js' );\r
- addButtonCommand( 'Button', 'button', dialogPath + 'button.js' );\r
- addButtonCommand( 'ImageButton', 'imagebutton', CKEDITOR.plugins.getPath('image') + 'dialogs/image.js' );\r
- addButtonCommand( 'HiddenField', 'hiddenfield', dialogPath + 'hiddenfield.js' );\r
-\r
- // If the "menu" plugin is loaded, register the menu items.\r
- if ( editor.addMenuItems )\r
- {\r
- editor.addMenuItems(\r
- {\r
- form :\r
- {\r
- label : lang.form.menu,\r
- command : 'form',\r
- group : 'form'\r
- },\r
-\r
- checkbox :\r
- {\r
- label : lang.checkboxAndRadio.checkboxTitle,\r
- command : 'checkbox',\r
- group : 'checkbox'\r
- },\r
-\r
- radio :\r
- {\r
- label : lang.checkboxAndRadio.radioTitle,\r
- command : 'radio',\r
- group : 'radio'\r
- },\r
-\r
- textfield :\r
- {\r
- label : lang.textfield.title,\r
- command : 'textfield',\r
- group : 'textfield'\r
- },\r
-\r
- hiddenfield :\r
- {\r
- label : lang.hidden.title,\r
- command : 'hiddenfield',\r
- group : 'hiddenfield'\r
- },\r
-\r
- imagebutton :\r
- {\r
- label : lang.image.titleButton,\r
- command : 'imagebutton',\r
- group : 'imagebutton'\r
- },\r
-\r
- button :\r
- {\r
- label : lang.button.title,\r
- command : 'button',\r
- group : 'button'\r
- },\r
-\r
- select :\r
- {\r
- label : lang.select.title,\r
- command : 'select',\r
- group : 'select'\r
- },\r
-\r
- textarea :\r
- {\r
- label : lang.textarea.title,\r
- command : 'textarea',\r
- group : 'textarea'\r
- }\r
- });\r
- }\r
-\r
- // If the "contextmenu" plugin is loaded, register the listeners.\r
- if ( editor.contextMenu )\r
- {\r
- editor.contextMenu.addListener( function( element )\r
- {\r
- if ( element && element.hasAscendant( 'form', true ) && !element.isReadOnly() )\r
- return { form : CKEDITOR.TRISTATE_OFF };\r
- });\r
-\r
- editor.contextMenu.addListener( function( element )\r
- {\r
- if ( element && !element.isReadOnly() )\r
- {\r
- var name = element.getName();\r
-\r
- if ( name == 'select' )\r
- return { select : CKEDITOR.TRISTATE_OFF };\r
-\r
- if ( name == 'textarea' )\r
- return { textarea : CKEDITOR.TRISTATE_OFF };\r
-\r
- if ( name == 'input' )\r
- {\r
- switch( element.getAttribute( 'type' ) )\r
- {\r
- case 'button' :\r
- case 'submit' :\r
- case 'reset' :\r
- return { button : CKEDITOR.TRISTATE_OFF };\r
-\r
- case 'checkbox' :\r
- return { checkbox : CKEDITOR.TRISTATE_OFF };\r
-\r
- case 'radio' :\r
- return { radio : CKEDITOR.TRISTATE_OFF };\r
-\r
- case 'image' :\r
- return { imagebutton : CKEDITOR.TRISTATE_OFF };\r
-\r
- default :\r
- return { textfield : CKEDITOR.TRISTATE_OFF };\r
- }\r
- }\r
-\r
- if ( name == 'img' && element.data( 'cke-real-element-type' ) == 'hiddenfield' )\r
- return { hiddenfield : CKEDITOR.TRISTATE_OFF };\r
- }\r
- });\r
- }\r
-\r
- editor.on( 'doubleclick', function( evt )\r
- {\r
- var element = evt.data.element;\r
-\r
- if ( element.is( 'form' ) )\r
- evt.data.dialog = 'form';\r
- else if ( element.is( 'select' ) )\r
- evt.data.dialog = 'select';\r
- else if ( element.is( 'textarea' ) )\r
- evt.data.dialog = 'textarea';\r
- else if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'hiddenfield' )\r
- evt.data.dialog = 'hiddenfield';\r
- else if ( element.is( 'input' ) )\r
- {\r
- switch ( element.getAttribute( 'type' ) )\r
- {\r
- case 'button' :\r
- case 'submit' :\r
- case 'reset' :\r
- evt.data.dialog = 'button';\r
- break;\r
- case 'checkbox' :\r
- evt.data.dialog = 'checkbox';\r
- break;\r
- case 'radio' :\r
- evt.data.dialog = 'radio';\r
- break;\r
- case 'image' :\r
- evt.data.dialog = 'imagebutton';\r
- break;\r
- default :\r
- evt.data.dialog = 'textfield';\r
- break;\r
- }\r
- }\r
- });\r
- },\r
-\r
- afterInit : function( editor )\r
- {\r
- var dataProcessor = editor.dataProcessor,\r
- htmlFilter = dataProcessor && dataProcessor.htmlFilter,\r
- dataFilter = dataProcessor && dataProcessor.dataFilter;\r
-\r
- // Cleanup certain IE form elements default values.\r
- if ( CKEDITOR.env.ie )\r
- {\r
- htmlFilter && htmlFilter.addRules(\r
- {\r
- elements :\r
- {\r
- input : function( input )\r
- {\r
- var attrs = input.attributes,\r
- type = attrs.type;\r
- // Old IEs don't provide type for Text inputs #5522\r
- if ( !type )\r
- attrs.type = 'text';\r
- if ( type == 'checkbox' || type == 'radio' )\r
- attrs.value == 'on' && delete attrs.value;\r
- }\r
- }\r
- } );\r
- }\r
-\r
- if ( dataFilter )\r
- {\r
- dataFilter.addRules(\r
- {\r
- elements :\r
- {\r
- input : function( element )\r
- {\r
- if ( element.attributes.type == 'hidden' )\r
- return editor.createFakeParserElement( element, 'cke_hidden', 'hiddenfield' );\r
- }\r
- }\r
- } );\r
- }\r
- },\r
- requires : [ 'image', 'fakeobjects' ]\r
-} );\r
-\r
-if ( CKEDITOR.env.ie )\r
-{\r
- CKEDITOR.dom.element.prototype.hasAttribute = CKEDITOR.tools.override( CKEDITOR.dom.element.prototype.hasAttribute,\r
- function( original )\r
- {\r
- return function( name )\r
- {\r
- var $attr = this.$.attributes.getNamedItem( name );\r
-\r
- if ( this.getName() == 'input' )\r
- {\r
- switch ( name )\r
- {\r
- case 'class' :\r
- return this.$.className.length > 0;\r
- case 'checked' :\r
- return !!this.$.checked;\r
- case 'value' :\r
- var type = this.getAttribute( 'type' );\r
- return type == 'checkbox' || type == 'radio' ? this.$.value != 'on' : this.$.value;\r
- }\r
- }\r
-\r
- return original.apply( this, arguments );\r
- };\r
- });\r
-}\r