From edc3af20c88d8ce61279ab36e6dee1d4091d8889 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 9 Feb 2013 07:17:40 +0400 Subject: [PATCH] updated docs in jli... Signed-off-by: Alex A. Naanou --- lib/jli.js | 17 +++++++++++++---- magazine.js | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/jli.js b/lib/jli.js index b47364b..2797695 100755 --- a/lib/jli.js +++ b/lib/jli.js @@ -11,24 +11,33 @@ /*********************************************************************/ -// XXX find a better name for this... -// this will create a function that will add/remove a css_class to elem +// this will create a function that will cycle through a class_list on elem // calling the optional callbacks before and/or after. +// if class_list is given as a string, then this will create a toggler that +// will turn the given class on the element on and off. // // elem is a jquery compatible object; default use-case: a css selector. // -// the resulting function understands the folowing arguments: +// if class_list is a list, the resulting function understands the +// folowing arguments: +// - : 0 for 'off' and 1 for 'on' (see below) // - 'on' : switch mode on // - 'off' : switch mode off // - '?' : return current state ('on'|'off') // - no arguments : toggle the state // +// otherwise: +// - : explicitly set the state to index in class_list +// - : explicitly set a class from the list +// - '?' : return current state ('on'|'off') +// - no arguments : set next state in cycle +// +// NOTE: must be an exact match to a string given in class_list // NOTE: of only one callback is given then it will be called after the // class change... // a way around this is to pass an empty function as callback_b // - function createCSSClassToggler(elem, class_list, callback_a, callback_b){ var bool_action = false if(typeof(class_list) == typeof('')){ diff --git a/magazine.js b/magazine.js index 7f40193..64b174b 100755 --- a/magazine.js +++ b/magazine.js @@ -70,7 +70,7 @@ var toggleInlineEditorMode = createCSSClassToggler('.viewer', 'inline-editor-mod // toggle between viewer themes... var toggleThemes = createCSSClassToggler('.viewer', [ 'light', - // this is the default... + // this is the default (no class set)... 'none', 'dark' ])