Skip to content

Initial setup#51

Open
gjunge wants to merge 11 commits intomasterfrom
claude/finish-vanilla-js-AJPyg
Open

Initial setup#51
gjunge wants to merge 11 commits intomasterfrom
claude/finish-vanilla-js-AJPyg

Conversation

@gjunge
Copy link
Copy Markdown
Owner

@gjunge gjunge commented Feb 21, 2026

No description provided.

gjunge and others added 11 commits April 18, 2017 17:03
Update gulpfile.js to build from src folder into scripts
Fix gulpfile.js to minify both rateit.js and jquery.rateit.js
* fix ispreset
* call value() when value is passed in options()
* reset() => revert() + implementation
* code cleaning
* Fix bug where preset is not reverted on clicking reset button
Bug fixes:
- Fix keyboard down-arrow using 'element' (string) instead of 'item' (HTMLElement) - broken since initial implementation
- Fix calcRawScore using global 'event' object instead of 'ev' parameter for touch/mouse detection
- Fix options() getter returning all values as strings, causing ispreset string "false" to be truthy and breaking reset button logic
- Fix value(el, null) not resetting to min (now mirrors jQuery version behaviour)
- Fix event listeners being bound unconditionally on readonly widgets (mousemove/mouseup/keyup now only bound when not readonly)
- Fix no guard against re-initialising already-initialised elements (enable() now calls redraw() and skips if init data present)

New features:
- Add DOMContentLoaded auto-initialisation for all .rateit elements (mirrors jQuery plugin behaviour)

Build:
- Compile src/rateit.ts to scripts/rateit.js (UMD module format, ES5 target)
- Update tsconfig.json: fix file reference from ./scripts/rateit.ts to ./src/rateit.ts, change module to umd
- Update gulpfile.js: pass module: 'umd' to typescript compiler

https://claude.ai/code/session_01HKMsCrHeceW42kMUtcJTCv
@gregh3269
Copy link
Copy Markdown

gregh3269 commented Mar 10, 2026

I had a look and the pr looks great.

A couple of things..

Comparing it to what I have:

a) If I don't supply a min value:

var _rateit = new rateit.rateit();
_rateit.enable('#id', { backingfld: "#bfid", max: 5, multiplier: 10, step: 0.5, value: 0, starheight: 30, starwidth: 30, });

later on the width calculation goes NaN :

range.style.width = "".concat(dataset.getNumber('starwidth') * (dataset.getNumber('max') - dataset.getNumber('min')), "px");

Adding a check on the options.min / max fixes it. ie || 0

dataset.set('min', isNaN(dataset.getNumber('min')) ? options.min || 0 : dataset.getNumber('min'));
dataset.set('max', isNaN(dataset.getNumber('max')) ? options.max || 0 : dataset.getNumber('max'));

b) Won't show my reset button, as I don't supply a default.

I think the jq version options extended defaults and then overriden on startup. So always had a default value.

c) I could not get it to run, ie work out how to initialise it on my page. Maybe need to use require(..) or something as its a module? I fudged the exports to make it work.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants