Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set class on form and buttons #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions js/jinplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
* @property {string} okButton - Create a submit button with this name
* @property {string} cancelButton - Create a cancel button with this name
* @property {string} inputClass - A css class that is added to the input field
* @property {string} formClass - A css class that is added to the form field
* @property {string} okClass - A css class that is added to the ok button
* @property {string} cancelClass - A css class that is added to the cancel button
* @property {jQuery|string} activator - Object (or css selector) for object to activate editing. Defaults to the element itself.
* @property {boolean} textOnly - When true (the default) text returned from server is displayed literally and not as html.
* @property {string} placeholder - Text to display in empty elements.
Expand All @@ -75,6 +78,9 @@
'okButton',
'cancelButton',
'inputClass',
'formClass',
'okClass',
'cancelClass',
'activator',
'textOnly',
'placeholder',
Expand Down Expand Up @@ -298,7 +304,7 @@
*
* @this {JinPlace}
* @param {editorBase} editor
* @param {Options} opts
* @param {Options} opts
*/
submit: function (editor, opts) {
var self = this;
Expand Down Expand Up @@ -467,6 +473,7 @@
var form = $("<form>")
.attr("style", "display: inline;")
.attr("action", "javascript:void(0);")
.addClass(opts.formClass)
.append(inputField);

if (buttons)
Expand All @@ -492,15 +499,17 @@

var ok = opts.okButton;
if (ok) {
var $button = $("<input>").attr("type", "button").attr("value", ok)
.addClass('jip-button jip-ok-button');
var $button = $("<button>").attr("type", "submit").html(ok)
.addClass('jip-button jip-ok-button')
.addClass(opts.okClass);
setHandler($button, 'submit');
}

var cancel = opts.cancelButton;
if (cancel) {
$button = $("<input>").attr("type", "button").attr("value", cancel)
.addClass('jip-button jip-cancel-button');
$button = $("<button>").attr("type", "submit").html(cancel)
.addClass('jip-button jip-cancel-button')
.addClass(opts.cancelClass);
setHandler($button, 'jip:cancel');
}
};
Expand Down