Permalink
Browse files

FEATURE Switched TreeDropdownField to use jquery.jstree instead of cu…

…stom tree.js library. Rewrote TreeDropdownField.js from behaviour.js to jquery.entwine.js
  • Loading branch information...
1 parent a00ccea commit 4b9ab5c8aaab8db77e34cbc3d40cf7b6c9e38895 @chillu chillu committed Mar 2, 2011
Showing with 52 additions and 665 deletions.
  1. +17 −52 css/TreeDropdownField.css
  2. +12 −14 forms/TreeDropdownField.php
  3. +23 −161 javascript/TreeDropdownField.js
  4. +0 −438 javascript/TreeSelectorField.js
View
@@ -1,76 +1,41 @@
div.TreeDropdownField {
- width: 35em;
- padding: 0;
-}
-html>body div.TreeDropdownField {
- position:relative;
-}
-
-div.TreeDropdownField {
- width: 27.7em;
- background: #fff;
- font-size: 12px;
+ width: 200px;
height: 21px;
}
div.TreeDropdownField span.items {
+ float: left;
+ overflow:hidden;
+ width: 174px;
height: 14px;
border: 1px #7f9db9 solid;
cursor: pointer;
- width: 25.4em;
- float: left;
- padding: 2px 0 2.5px 4px;
+ padding: 2px 0 2px 4px;
background-color: #fff;
- margin:0;
- font-size: 12px;
- overflow:hidden;
}
-div.TreeDropdownField div.tree_holder {
- clear: left;
+div.TreeDropdownField .panel {
+ position:relative;
+ overflow: auto;
+ display: none;
+ z-index: 1000;
cursor: default;
border: 1px black solid;
- margin: 0;
+ width: 200px;
height: 200px;
- overflow: auto;
background-color: #fff;
- /**
- * HACK IE6, see http://www.hedgerwow.com/360/bugs/css-select-free.html
- */
- position:absolute;
- z-index:10;
- width:33em;/*must have for any value*/;
}
-div.TreeDropdownField div.tree_holder ul.tree a {
- font-size: 12px;
+div.TreeDropdownField .panel.loading {
+ background: #f00;
}
-div.TreeDropdownField div.tree_holder ul.tree {
- margin-top: 0;
-}
-
-html>body div.TreeDropdownField div.tree_holder {
- top: 20px;
- left: 0px;
- z-index: 1000;
+div.TreeDropdownField .panel ul.tree a {
+ font-size: 12px;
}
-/**
- * HACK IE6, see http://www.hedgerwow.com/360/bugs/css-select-free.html
- */
-div.TreeDropdownField div.tree_holder iframe {
- display:none;/* IE5*/
- display/**/:block;/* IE5*/
- position:absolute;
- border-style: none;
- top:0;
- left:0;
- z-index:-1;
- filter:mask();
- width:31em;/*must have for any big value*/
- height:200px/*must have for any big value*/;
- border: none;
+div.TreeDropdownField .panel ul.tree {
+ margin-top: 0;
}
div.TreeDropdownField a.editLink {
@@ -115,16 +115,13 @@ public function setSearchFunction($callback) {
public function Field() {
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
- Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
- Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
- Requirements::javascript(SAPPHIRE_DIR . '/javascript/tree/tree.js');
- // needed for errorMessage()
- Requirements::javascript(SAPPHIRE_DIR . '/javascript/LeftAndMain.js');
- Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeSelectorField.js');
+ Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
+ Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jstree/jquery.jstree.js');
+ Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeDropdownField.js');
- Requirements::css(SAPPHIRE_DIR . '/javascript/tree/tree.css');
+ Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css');
Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css');
if($this->Value() && $record = $this->objectForKey($this->Value())) {
@@ -138,7 +135,7 @@ public function Field() {
array (
'id' => "TreeDropdownField_{$this->id()}",
'class' => 'TreeDropdownField single' . ($this->extraClass() ? " {$this->extraClass()}" : ''),
- 'href' => $this->form ? $this->Link() : "",
+ 'href' => $this->form ? $this->Link('tree') : "",
),
$this->createTag (
'input',
@@ -152,7 +149,7 @@ public function Field() {
$this->createTag(
'input',
array(
- 'class' => 'items',
+ 'class' => 'title',
'value' => '(Choose or type search)'
)
) :
@@ -197,7 +194,8 @@ public function tree(SS_HTTPRequest $request) {
$this->search = Convert::Raw2SQL($request->getVar('search'));
- if($ID = (int) $request->latestparam('ID')) {
+ $ID = (is_numeric($request->latestparam('ID'))) ? (int)$request->latestparam('ID') : (int)$request->requestVar('ID');
+ if($ID) {
$obj = DataObject::get_by_id($this->sourceObject, $ID);
$isSubTree = true;
@@ -232,15 +230,15 @@ public function tree(SS_HTTPRequest $request) {
$obj->markToExpose($this->objectForKey($value));
}
}
-
- $eval = '"<li id=\"selector-' . $this->Name() . '-{$child->' . $this->keyField . '}\" class=\"$child->class"' .
+
+ $eval = '"<li id=\"selector-' . $this->Name() . '-{$child->' . $this->keyField . '}\" data-id=\"$child->' . $this->keyField . '\" class=\"$child->class"' .
' . $child->markingClasses() . "\"><a rel=\"$child->ID\">" . $child->' . $this->labelField . ' . "</a>"';
if($isSubTree) {
return substr(trim($obj->getChildrenAsUL('', $eval, null, true)), 4, -5);
+ } else {
+ return $obj->getChildrenAsUL('class="tree"', $eval, null, true);
}
-
- return $obj->getChildrenAsUL('class="tree"', $eval, null, true);
}
/**
Oops, something went wrong.

0 comments on commit 4b9ab5c

Please sign in to comment.