-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #62; Removed Dependance on jQuery
Completely removed jQuery as a dependancy of Epoch by creating a mini querying system for the library. Basically I hunted down all the ways that jQuery was being used and ensured that we mirrored the functionality using regular JavaScript. The new querying system, named `Epoch.Query` is where most of the heavy lifting takes place. In places where mirroring functionality seemed out of scope, or could be easily achieved with a simple call or two, I opted not to mirror functionality. One example is that of generating elements directly from html strings. This change touches quite a few places in the library and fundamentally changes the way we handle DOM querying and manipulation. As such, it would be prudent to get a few eyes on these changes before merging it into master.
- Loading branch information
Showing
5 changed files
with
195 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
do -> | ||
return unless window.jQuery | ||
|
||
# Data key to use for storing a reference to the chart instance on an element. | ||
DATA_NAME = 'epoch-chart' | ||
# Data key to use for storing a reference to the chart instance on an element. | ||
DATA_NAME = 'epoch-chart' | ||
|
||
# Adds an Epoch chart of the given type to the referenced element. | ||
# @param [Object] options Options for the chart. | ||
# @option options [String] type The type of chart to append to the referenced element. | ||
# @return [Object] The chart instance that was associated with the containing element. | ||
jQuery.fn.epoch = (options) -> | ||
options.el = @ | ||
unless (chart = @.data(DATA_NAME))? | ||
klass = Epoch._typeMap[options.type] | ||
unless klass? | ||
Epoch.exception "Unknown chart type '#{options.type}'" | ||
@.data DATA_NAME, (chart = new klass options) | ||
chart.draw() | ||
return chart | ||
# Adds an Epoch chart of the given type to the referenced element. | ||
# @param [Object] options Options for the chart. | ||
# @option options [String] type The type of chart to append to the referenced element. | ||
# @return [Object] The chart instance that was associated with the containing element. | ||
jQuery.fn.epoch = (options) -> | ||
options.el = @.get(0) | ||
unless (chart = @.data(DATA_NAME))? | ||
klass = Epoch._typeMap[options.type] | ||
unless klass? | ||
Epoch.exception "Unknown chart type '#{options.type}'" | ||
@.data DATA_NAME, (chart = new klass options) | ||
chart.draw() | ||
return chart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.