Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marco Braak
committed
Oct 1, 2014
1 parent
5a77289
commit a47e9ad
Showing
21 changed files
with
4,996 additions
and
2,249 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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
gulp = require 'gulp' | ||
coffee = require 'gulp-coffee' | ||
coffeeify = require 'gulp-coffeeify' | ||
exec = require('child_process').exec | ||
|
||
gulp.task 'jqtree', -> | ||
gulp.src './src/tree.jquery.coffee' | ||
.pipe coffeeify() | ||
.pipe gulp.dest('./') | ||
|
||
gulp.task 'lib', -> | ||
gulp.src './src/*.coffee' | ||
.pipe coffee(bare: true) | ||
.pipe gulp.dest('./lib') | ||
|
||
gulp.task 'build_test', -> | ||
gulp.src './src/test.js' | ||
.pipe coffeeify() | ||
.pipe gulp.dest('./test') | ||
|
||
gulp.task 'jekyll', (cb) -> | ||
exec 'jekyll build', (err, stdout, stderr) -> | ||
console.log(stdout) | ||
console.log(stderr) | ||
cb(err) | ||
|
||
gulp.task 'default', ['jqtree', 'build_test', 'lib'] |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require('coffee-script/register'); | ||
require('./gulpfile.coffee'); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "jqtree", | ||
"version": "0.22.0", | ||
"description": "Tree widget for jQuery", | ||
"main": "lib/tree.jquery.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mbraak/jqtree" | ||
}, | ||
"dependencies": { | ||
"jquery": ">1.5" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "1.8.0", | ||
"gulp": "3.8.8", | ||
"gulp-coffee": "2.2.0", | ||
"gulp-coffeeify": "0.1.2" | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
node = require './node' | ||
Position = node.Position | ||
|
||
|
||
class NodeElement | ||
constructor: (node, tree_widget) -> | ||
@init(node, tree_widget) | ||
|
||
init: (node, tree_widget) -> | ||
@node = node | ||
@tree_widget = tree_widget | ||
|
||
if not node.element | ||
node.element = @tree_widget.element | ||
|
||
@$element = $(node.element) | ||
|
||
getUl: -> | ||
return @$element.children('ul:first') | ||
|
||
getSpan: -> | ||
return @$element.children('.jqtree-element').find('span.jqtree-title') | ||
|
||
getLi: -> | ||
return @$element | ||
|
||
addDropHint: (position) -> | ||
if position == Position.INSIDE | ||
return new BorderDropHint(@$element) | ||
else | ||
return new GhostDropHint(@node, @$element, position) | ||
|
||
select: -> | ||
@getLi().addClass('jqtree-selected') | ||
|
||
deselect: -> | ||
@getLi().removeClass('jqtree-selected') | ||
|
||
|
||
class FolderElement extends NodeElement | ||
open: (on_finished, slide=true) -> | ||
if not @node.is_open | ||
@node.is_open = true | ||
$button = @getButton() | ||
$button.removeClass('jqtree-closed') | ||
$button.html('') | ||
$button.append(@tree_widget.renderer.opened_icon_element.cloneNode()) | ||
|
||
doOpen = => | ||
@getLi().removeClass('jqtree-closed') | ||
if on_finished | ||
on_finished() | ||
|
||
@tree_widget._triggerEvent('tree.open', node: @node) | ||
|
||
if slide | ||
@getUl().slideDown('fast', doOpen) | ||
else | ||
@getUl().show() | ||
doOpen() | ||
|
||
close: (slide=true) -> | ||
if @node.is_open | ||
@node.is_open = false | ||
$button = @getButton() | ||
$button.addClass('jqtree-closed') | ||
$button.html('') | ||
$button.append(@tree_widget.renderer.closed_icon_element.cloneNode()) | ||
|
||
doClose = => | ||
@getLi().addClass('jqtree-closed') | ||
|
||
@tree_widget._triggerEvent('tree.close', node: @node) | ||
|
||
if slide | ||
@getUl().slideUp('fast', doClose) | ||
else | ||
@getUl().hide() | ||
doClose() | ||
|
||
getButton: -> | ||
return @$element.children('.jqtree-element').find('a.jqtree-toggler') | ||
|
||
addDropHint: (position) -> | ||
if not @node.is_open and position == Position.INSIDE | ||
return new BorderDropHint(@$element) | ||
else | ||
return new GhostDropHint(@node, @$element, position) | ||
|
||
|
||
class BorderDropHint | ||
constructor: ($element) -> | ||
$div = $element.children('.jqtree-element') | ||
width = $element.width() - 4 | ||
|
||
@$hint = $('<span class="jqtree-border"></span>') | ||
$div.append(@$hint) | ||
|
||
@$hint.css( | ||
width: width | ||
height: $div.height() - 4 | ||
) | ||
|
||
remove: -> | ||
@$hint.remove() | ||
|
||
|
||
class GhostDropHint | ||
constructor: (node, $element, position) -> | ||
@$element = $element | ||
|
||
@node = node | ||
@$ghost = $('<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"></span><span class="jqtree_common jqtree-line"></span></li>') | ||
|
||
if position == Position.AFTER | ||
@moveAfter() | ||
else if position == Position.BEFORE | ||
@moveBefore() | ||
else if position == Position.INSIDE | ||
if node.isFolder() and node.is_open | ||
@moveInsideOpenFolder() | ||
else | ||
@moveInside() | ||
|
||
remove: -> | ||
@$ghost.remove() | ||
|
||
moveAfter: -> | ||
@$element.after(@$ghost) | ||
|
||
moveBefore: -> | ||
@$element.before(@$ghost) | ||
|
||
moveInsideOpenFolder: -> | ||
$(@node.children[0].element).before(@$ghost) | ||
|
||
moveInside: -> | ||
@$element.after(@$ghost) | ||
@$ghost.addClass('jqtree-inside') | ||
|
||
|
||
module.exports = | ||
FolderElement: FolderElement | ||
NodeElement: NodeElement |
Oops, something went wrong.