Skip to content

Commit

Permalink
Updated gh-pages with new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Nov 2, 2012
1 parent 99f1521 commit bf6c502
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/
Empty file added .nojekyll
Empty file.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
all: clean docs
all: clean docs publish

clean:
rm -rf docs
mkdir docs

docs:
jsduck . --output docs


jsduck deps.js --title="jQuery Interdependencies" --output docs --external=jQuery

publish:
./publish-docs.sh
12 changes: 9 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
.. contents:: :local:

Introduction
---------------

**jQuery Interdependencies* is a jQuery plug-in to
manage HTML form field interdependencies.
It is a helper library for building complex conditional forms.
**jQuery Interdependencies** is a Javascript library to
create rules for managing HTML form field interdependencies.
It is a helper library for building complex conditional forms
where fields are shown and hidden depending on values in other fields.

Features
---------

* Show and hide fields based on other field values

Expand Down
112 changes: 83 additions & 29 deletions deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"use strict";

/**
* Microsoft wrapper
* Microsoft helper
*
* @ignore
*/
function log(msg) {
if(console && console.log) {
Expand All @@ -14,7 +16,9 @@
}

/**
* Sample configuration object
* Sample configuration object which can be passed to {@link jQuery.deps#enable}
*
* @class Configuration
*/
var configExample = {

Expand All @@ -26,12 +30,12 @@

/**
* @cfg hide Callback function hide(elem) for hiding elements
* @type {Functoin}
* @type {Function}
*/
hide : null,

/**
* @cfg log Write log output of rule applying
* @cfg log Write console.log() output of rule applying
* @type {Boolean}
*/
log : false
Expand All @@ -43,36 +47,52 @@
* When condition is true then this input and all
* its children rules' inputs are visible.
*
* Possible conditions:
* "==" Widget value must be equal to given value
* "any" Widget value must be any of the values in the given value array
* "non-any" Widget value must not be any of the values in the given value array
* "!=" Widget value must not be qual to given value
* "()" Call value as a function(context, controller, ourWidgetValue) and if it's true then the condition is true
* null This input does not have any sub-conditions
* Possible condition strings:
*
* * **==** Widget value must be equal to given value
*
* * **any** Widget value must be any of the values in the given value array
*
* @param {String} controller jQuery expression to match the input
* * **non-any** Widget value must not be any of the values in the given value array
*
* * **!=** Widget value must not be qual to given value
*
* * **()** Call value as a function(context, controller, ourWidgetValue) and if it's true then the condition is true
*
* * **null** This input does not have any sub-conditions
*
* @param {String} condition What input value must be that the rule takes effective.
*
* @param value What value the condition must be to make controlled widgets visible
*
*/
function Rule(controller, condition, value) {
this.controller = controller;
this.init(controller, condition, value);
}

$.extend(Rule.prototype, {

this.condition = condition;
/**
* @method constructor
*
* @param {String} controller jQuery expression to match the `<input>` source
*
* @param {String} condition What input value must be that {@link Rule the rule takes effective}.
*
* @param value Matching value of **controller** when widgets become visible
*
*/
init : function(controller, condition, value) {
this.controller = controller;

this.value = value;
this.condition = condition;

// Child rules
this.rules = [];
this.value = value;

// Controls shown/hidden by this rule
this.controls = [];
}
// Child rules
this.rules = [];

$.extend(Rule.prototype, {
// Controls shown/hidden by this rule
this.controls = [];
},

/**
* Evaluation engine
Expand Down Expand Up @@ -167,6 +187,11 @@
/**
* Create a sub-rule.
*
* Example:
*
* var masterSwitch = ruleset.createRule("#mechanicalThrombectomyDevice")
* var twoAttempts = masterSwitch.createRule("#numberOfAttempts", "==", 2);
*
* @return Rule instance
*/
createRule : function(controller, condition, value) {
Expand All @@ -189,9 +214,7 @@
*
* @param {jQuery} context jQuery selection within we operate
* @param {Object} cfg Configuration object or empty object
* @param {Object} enforced Recursive rule enforcer: undefined to evaluate condition,
* true show always,
* false hide always
* @param {Object} enforced Recursive rule enforcer: undefined to evaluate condition, true show always, false hide always
*
*/
applyRule : function(context, cfg, enforced) {
Expand Down Expand Up @@ -261,6 +284,12 @@

$.extend(Ruleset.prototype, {

/**
* Add a new rule into this ruletset.
*
* See {@link Rule} about the contstruction parameters.
* @return {Rule}
*/
createRule : function(controller, condition, value) {
var rule = new Rule(controller, condition, value);
this.rules.push(rule);
Expand All @@ -287,7 +316,10 @@
},

/**
* Make this ruleset effective on the whole page
* Make this ruleset effective on the whole page.
*
* Set event handler on **window.document** to catch all input events
* and apply those events to defined rules.
*/
install : function(cfg) {
$.deps.enable($(document), this, cfg);
Expand All @@ -296,15 +328,37 @@

});

/**
* jQuery interdependencie plug-in
*
* @class jQuery.deps
*
*/
var deps = {

/**
* Create a new Ruleset instance.
*
* Example:
*
* $(document).ready(function() {
* // Start creating a new ruleset
* var ruleset = $.deps.createRuleset();
*
*
* @return {Ruleset}
*/
createRuleset : function() {
return new Ruleset();
},

apply : function(cfg) {
},

/**
* Enable ruleset on a specific jQuery selection
* @param {Object} selection jQuery selection
* @param {Ruleset} ruleset
* @param {Configuration} cfg
*/
enable : function(selection, ruleset, cfg) {

cfg = cfg || {};
Expand Down
1 change: 1 addition & 0 deletions jquery-interdependencies
Submodule jquery-interdependencies added at 99f152
31 changes: 31 additions & 0 deletions publish-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# Push docs to GitHub
#
# Run:
#
# sh scripts/publish-docs.sh
#
# CSS issues: https://github.com/blog/572-bypassing-jekyll-on-github-pages
#

SOURCE=`pwd`

TARGET=/tmp/docs-dist

rm -rf $TARGET/gh-pages
mkdir $TARGET/gh-pages

cd $TARGET
# Need to have gh-pages initialized first http://help.github.com/pages/
git clone -b gh-pages git@github.com:miohtama/jquery-interdependencies.git gh-pages

cd gh-pages
# CSS issues: https://github.com/blog/572-bypassing-jekyll-on-github-pages
touch .nojekyll
cp -r $SOURCE .
git add -A
git commit -m "Updated gh-pages with new docs"
git push origin gh-pages
cd ..
cd ..

0 comments on commit bf6c502

Please sign in to comment.