- JoB.js -

Introduction

Rails inspired helpers library for Javascript.

JoB.Lib.UrlHelper Setup

Make the helper available:

window.urlHelper = new JoB.Lib.UrlHelper()

linkTohelper.linkTo(body, url, htmlOptions = {})
Creates a button element that defines a submit button.

urlHelper.linkTo("google.com", "https://www.google.de/",
  {target: '_new'}
);

Form.TagHelper Setup

Make the helper available:

window.helper = new JoB.Form.TagHelper()

buttonTaghelper.buttonTag(content, [htmlOptions])
Creates a button element that defines a submit button.

helper.buttonTag("Save");

dateFieldTaghelper.dateFieldTag(content, [htmlOptions])
Creates a button element that defines a submit button.

helper.dateFieldTag("user", "birthday");

datetimeLocalFieldTagnot implemented

datetimeFieldTaghelper.datetimeFieldTag(content, [htmlOptions])
Creates a button element that defines a submit button.

helper.datetimeFieldTag("user", "birthday");

emailFieldTaghelper.emailFieldTag(ressourceName, fieldName, [htmlOptions])
Creates a button element that defines a submit button.

helper.emailFieldTag("user", "email");

fileFieldTaghelper.fileFieldTag(ressourceName, fieldName, [htmlOptions])
Creates a button element that defines a submit button.

helper.fileFieldTag("user", "avatars", {multiple: true});

formTagnot implemented

hiddenFieldTaghelper.hiddenFieldTag(ressourceName, fieldName, [htmlOptions])
Creates a button element that defines a submit button.

helper.hiddenFieldTag("user", "account_id");

imageSubmitTaghelper.imageSubmitTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.imageSubmitTag("/docs/images/arrows.png");

labelTaghelper.labelTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.labelTag("email", "E-Mail", {css: {color: '#aaa'}});

monthFieldTaghelper.monthFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.monthFieldTag("user", "birthday");

numberFieldTaghelper.numberFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.numberFieldTag("apples", "quantity", {min: 3});

passwordFieldTaghelper.passwordFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.passwordFieldTag("user", "password");

phoneFieldTaghelper.phoneFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.phoneFieldTag("user", "mobile");

radioButtonTaghelper.radioButtonTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.radioButtonTag("user", "gender", true, {value: 'male'});

rangeFieldTaghelper.rangeFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.rangeFieldTag("user", "gender", {onchange: "console.log(this.value)"});

searchFieldTaghelper.searchFieldTag(src, [htmlOptions])
Creates a button element that defines a submit button.

helper.searchFieldTag("user", "gender");

selectTaghelper.selectTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.selectTag("user", "gender",
  optionHelper.optionsForSelect(
    [['m','Male'],['f','Female']], 'f'
  )
);

submitTaghelper.submitTag(ressourceName, fieldName, optionTags = null, options={})

helper.submitTag("Save changes");

telephoneFieldTagalias for phoneFieldTag

textAreaTaghelper.textAreaTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.textAreaTag("user", "comment");

textFieldTaghelper.textFieldTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.textFieldTag("user", "name");

timeFieldTaghelper.timeFieldTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.timeFieldTag("restaurant", "shopping_hours_from", {value: "10:00"});

urlFieldTaghelper.urlFieldTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.urlFieldTag("restaurant", "domain");

utf8EnforcerTagnot implemented

weekFieldTaghelper.weekFieldTag(ressourceName, fieldName, optionTags = null, options={})
Check optionsFromCollectionForSelect or optionsForSelect for generating options tags

helper.weekFieldTag("restaurant", "domain");

JoB.Form.OptionsHelper Setup

Make the helper available:

window.optionHelper = new JoB.Form.OptionsHelper()

optionsFromCollectionForSelectoptionHelper.optionsFromCollectionForSelect(collection, valueMethod = 'id', textMethod = 'name', selected = null)

models = [
  new Backbone.Model({id: 1, name: 'Ruby'}),
  new Backbone.Model({id: 2, name: 'Javascript'})
]
optionHelper.optionsFromCollectionForSelect(
  new Backbone.Collection(models),
  'id',
  'name',
  models[1]
);

optionsForSelectoptionHelper.optionsForSelect(collectioncollection, selected=null)

options = ['yes', 'no'];
optionHelper.optionsForSelect(options, options[1]);

options = [['1', 'yes'], ['0', 'no']];
optionHelper.optionsForSelect(options, options[1]);