Changeset 1833
- Timestamp:
- 11/02/06 12:09:55 (2 years ago)
- Files:
-
- rubricks_core/trunk/public/images/spinelz/tabBox_close.gif (added)
- rubricks_core/trunk/public/javascripts/spinelz/balloon.js (modified) (3 diffs)
- rubricks_core/trunk/public/javascripts/spinelz/datepicker.js (modified) (7 diffs)
- rubricks_core/trunk/public/javascripts/spinelz/tabBox.js (modified) (11 diffs)
- rubricks_core/trunk/public/javascripts/spinelz/window.js (modified) (17 diffs)
- rubricks_core/trunk/public/javascripts/spinelz/window_resizeEx.js (modified) (1 diff)
- rubricks_core/trunk/public/javascripts/spinelz_lib/spinelz_util.js (modified) (1 diff)
- rubricks_core/trunk/public/stylesheets/spinelz/tabBox.css (modified) (5 diffs)
- rubricks_core/trunk/public/stylesheets/spinelz/window.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
rubricks_core/trunk/public/javascripts/spinelz/balloon.js
r1596 r1833 29 29 balloon_tooltip: 'balloon_tooltip' 30 30 } 31 Balloon.allBalloons = $A([]); 32 Balloon.closeAll = function(){ 33 Balloon.allBalloons.each(function(eachBalloon){ 34 eachBalloon.close(); 35 }); 36 } 31 37 Balloon.prototype = { 32 38 initialize : function (target_id, tip_id, message){ … … 44 50 document.body.appendChild(this.tipNode, this.target); 45 51 this._positionTipNode(); 46 Event.observe(this.tipNode, 'click', this.close.bind(this), true) 52 Event.observe(this.tipNode, 'click', this.close.bind(this), true) 53 Balloon.allBalloons.push(this) 47 54 }, 48 55 … … 63 70 top: tipNodeTop + 'px', 64 71 left: tipNodeLeft + 'px', 65 zIndex: Element.getMaxZindex() + 272 zIndex: ZindexManager.getIndex() 66 73 }); 67 74 }, rubricks_core/trunk/public/javascripts/spinelz/datepicker.js
r1563 r1833 36 36 nextYearMark: 'datepicker_nextYearMark', 37 37 preMonthMark: 'datepicker_preMonthMark', 38 preYearMark: 'datepicker_preYearMark' 38 preYearMark: 'datepicker_preYearMark', 39 zIndex: null 39 40 } 40 41 DatePicker.prototype = { … … 46 47 this.date = new Date(); 47 48 48 varoptions = Object.extend({49 this.options = Object.extend({ 49 50 month: this.date.getMonth() + 1, 50 51 date: this.date.getDate(), … … 52 53 format: DateUtil.toLocaleDateString, 53 54 cssPrefix: 'custom_', 54 callBack: Prototype.emptyFunction 55 callBack: Prototype.emptyFunction, 56 standTo: false, 57 beforeShow: Prototype.emptyFunction 55 58 }, arguments[3] || {}); 56 59 57 var customCss = CssUtil.appendPrefix( options.cssPrefix, DatePicker.className);60 var customCss = CssUtil.appendPrefix(this.options.cssPrefix, DatePicker.className); 58 61 this.classNames = new CssUtil([DatePicker.className, customCss]); 59 62 60 this.format = options.format;61 this.callBack = options.callBack;62 63 this.date.setMonth( options.month - 1);64 this.date.setDate( options.date);65 this.date.setFullYear( options.year);63 this.format = this.options.format; 64 this.callBack = this.options.callBack; 65 66 this.date.setMonth(this.options.month - 1); 67 this.date.setDate(this.options.date); 68 this.date.setFullYear(this.options.year); 66 69 67 70 this.calendar = this.build(); … … 244 247 245 248 changeCalendar: function(event) { 246 var element = Event.element(event); 247 if (Element.hasClassName(element, DatePicker.className.preYearMark)) { 249 var element = Event.element(event); 250 if (Element.hasClassName(element, DatePicker.className.preYearMark)) { 251 this.date.setFullYear(this.date.getFullYear() - 1); 252 } else if (Element.hasClassName(element, DatePicker.className.nextYearMark)) { 253 this.date.setFullYear(this.date.getFullYear() + 1); 254 } else if (Element.hasClassName(element, DatePicker.className.preMonthMark)) { 255 var pre = this.date.getMonth() - 1; 256 if (pre < 0) { 257 pre = 11; 248 258 this.date.setFullYear(this.date.getFullYear() - 1); 249 } else if (Element.hasClassName(element, DatePicker.className.nextYearMark)) { 259 } 260 this.date.setMonth(pre); 261 } else if (Element.hasClassName(element, DatePicker.className.nextMonthMark)) { 262 var next = this.date.getMonth() + 1; 263 if (next > 11) { 264 next = 0; 250 265 this.date.setFullYear(this.date.getFullYear() + 1); 251 } else if (Element.hasClassName(element, DatePicker.className.preMonthMark)) {252 var pre = this.date.getMonth() - 1;253 if (pre < 0) {254 pre = 11;255 this.date.setFullYear(this.date.getFullYear() - 1);256 }257 this.date.setMonth(pre);258 } else if (Element.hasClassName(element, DatePicker.className.nextMonthMark)) {259 var next = this.date.getMonth() + 1;260 if (next > 11) {261 next = 0;262 this.date.setFullYear(this.date.getFullYear() + 1);263 }264 this.date.setMonth(next);265 266 } 266 267 this.refresh(); 268 if (event) Event.stop(event); 267 this.date.setMonth(next); 268 } 269 270 this.refresh(); 271 if (event) Event.stop(event); 269 272 }, 270 273 … … 276 279 277 280 var value = this.format(this.date); 278 279 281 280 282 if (this.target.value || this.target.value == '') { … … 291 293 292 294 show: function(event) { 295 var styles = $H({zIndex: ZindexManager.getIndex(this.options.zIndex)}); 296 if (this.options.standTo) { 297 this.defaultParent = this.element.parentNode; 298 document.body.appendChild(this.element); 299 var position = Position.cumulativeOffset(document.body); 300 styles.merge({ 301 position: 'absolute', 302 left: Event.pointerX(event) - position[0] + 'px', 303 top: Event.pointerY(event) - position[1] + 'px' 304 }); 305 } 306 307 Element.setStyle(this.element, styles); 293 308 Element.show(this.calendar); 294 309 Event.observe(document, "click", this.doclistener); 295 310 if (event) { 296 Event.stop(event);311 Event.stop(event); 297 312 } 298 313 }, … … 301 316 Event.stopObserving(document, "click", this.doclistener); 302 317 Element.hide(this.calendar); 318 if (this.defaultParent) { 319 this.defaultParent.appendChild(this.element); 320 } 303 321 }, 304 322 rubricks_core/trunk/public/javascripts/spinelz/tabBox.js
r1563 r1833 22 22 TabBox = Class.create(); 23 23 TabBox.className = { 24 tabBox : 'tabBox_tabBox', 24 25 panelContainer : 'tabBox_panelContainer', 25 26 tabContainer : 'tabBox_tabContainer', … … 30 31 tabMiddleActive : 'tabBox_tabMiddleActive', 31 32 tabRightInactive : 'tabBox_tabRightInactive', 32 tabRightActive : 'tabBox_tabRightActive' 33 tabRightActive : 'tabBox_tabRightActive', 34 tabTitle: 'tabBox_tabTitle', 35 closeButton : 'tabBox_closeButton' 33 36 } 34 37 TabBox.prototype = { … … 40 43 height: 300, 41 44 cssPrefix: 'custom_', 42 afterSelect: Prototype.emptyFunction 45 afterSelect: Prototype.emptyFunction, 46 onRemove: function() {return true}, 47 sortable: false, 48 closeButton: false, 49 afterSort: Prototype.emptyFunction, 50 onSort: Prototype.emptyFunction, 51 lazyLoadUrl: [], 52 onLazyLoad: Prototype.emptyFunction, 53 afterLazyLoad: Prototype.emptyFunction 43 54 }, arguments[1] || {}); 44 55 … … 51 62 var customCss = CssUtil.appendPrefix(this.options.cssPrefix, TabBox.className); 52 63 this.classNames = new CssUtil([TabBox.className, customCss]); 64 this.classNames.addClassNames(this.element, 'tabBox'); 53 65 54 66 this.start(); 55 67 Element.setStyle(this.element, {visibility: 'visible'}); 56 68 Element.show(this.element); 69 70 if (this.options.lazyLoadUrl.length > 0) this.lazyLoad(0)(); 57 71 }, 58 72 … … 71 85 this.tabContainer = null; 72 86 this.panelContainer = null; 73 74 87 this.build(); 88 if (this.options.sortable) this.setDrag(); 89 }, 90 91 setDrag: function() { 92 Sortable.create(this.tabContainerId, { 93 tag:'div', 94 overlap:'horizontal', 95 constraint: 'horizontal', 96 onChange: this.options.onSort, 97 onUpdate: this.options.afterSort 98 }); 75 99 }, 76 100 … … 86 110 var i = 0; 87 111 while(tabSets.length > 0) { 88 var tabSet = tabSets[0]; 89 90 if (tabSet.nodeType != 1) { 91 Element.remove(tabSet); 92 continue; 93 } 94 Element.cleanWhitespace(tabSet); 95 var panelContents = tabSet.childNodes[1]; 96 this.buildPanel(panelContents, i); 97 98 this.buildTab(tabSet, i); 112 this.buildTabSet(tabSets[0], i); 99 113 i++; 100 114 } 101 115 this.addContainers(); 102 116 this.selectTab(); 117 }, 118 119 buildTabSet: function(element, i) { 120 if (element.nodeType != 1) { 121 Element.remove(element); 122 return; 123 } 124 Element.cleanWhitespace(element); 125 var panelContents = element.childNodes[1]; 126 this.buildPanel(panelContents, i); 127 this.buildTab(element, i); 103 128 }, 104 129 … … 107 132 this.classNames.addClassNames(this.tabContainer, 'tabContainer'); 108 133 109 this.panelContainer = Builder.node('div', 110 { 111 id:this.panelContainerId 112 } 113 ); 134 this.panelContainer = Builder.node('div', {id:this.panelContainerId}); 114 135 this.classNames.addClassNames(this.panelContainer, 'panelContainer'); 115 136 }, … … 123 144 tab.id = this.tabId + i 124 145 this.classNames.addClassNames(tab, 'tab'); 125 var tabTitle = tab.childNodes; 146 var tabTitle = Builder.node('div', [$A(tab.childNodes)]); 147 this.classNames.addClassNames(tabTitle, 'tabTitle'); 126 148 var tabLeft = Builder.node('div', {id:this.tabLeftId + i}); 127 var tabMiddle = Builder.node('div', {id:this.tabMiddleId + i}, $A(tabTitle));149 var tabMiddle = Builder.node('div', {id:this.tabMiddleId + i}, [tabTitle]); 128 150 129 151 var tabRight = Builder.node('div',{id:this.tabRightId + i}); … … 133 155 tab.appendChild(tabRight); 134 156 Event.observe(tab, 'click', this.selectTab.bindAsEventListener(this)); 157 158 if (this.options.closeButton) { 159 var button = Builder.node('div', { 160 id: this.element.id.appendSuffix('closeButton_' + i) 161 }); 162 this.classNames.addClassNames(button, 'closeButton'); 163 tabMiddle.appendChild(button); 164 Event.observe(button, 'click', this.remove.bindAsEventListener(this)); 165 } 135 166 136 167 this.tabs[i] = tab; … … 171 202 172 203 this.selected = targetIndex; 173 this.options.afterSelect( );204 this.options.afterSelect(targetPanel, currentPanel); 174 205 }, 175 206 … … 200 231 element = element.parentNode; 201 232 } 233 }, 234 235 remove: function(event) { 236 Event.stop(event); 237 var element = Event.element(event); 238 var index = this.getTargetIndex(element); 239 if (this.options.onRemove(this.tabs[index])) { 240 Element.remove(this.tabs[index]); 241 Element.remove(this.panelList[index]); 242 } 243 }, 244 245 addByElement: function(element) { 246 this.buildTabSet($(element), this.tabs.length); 247 if (this.options.sortable) this.setDrag(); 248 }, 249 250 add: function(title, content) { 251 var container = Builder.node('div'); 252 container.appendChild(Builder.node('div', [title])); 253 container.appendChild(Builder.node('div', [content])); 254 this.addByElement(container); 255 }, 256 257 lazyLoad: function(index) { 258 var container = this.panelList[index]; 259 var url = this.options.lazyLoadUrl[index]; 260 var preContainer = this.panelList[index - 1]; 261 var self = this; 262 263 if (container && url) { 264 var afterLoad = null; 265 if (index > 0) { 266 afterLoad = this.options.onLazyLoad; 267 } else { 268 afterLoad = Prototype.emptyFunction; 269 } 270 var onComplete = this.lazyLoad(++index); 271 return function() { 272 afterLoad(preContainer, this); 273 new Ajax.Updater( 274 container, 275 url, 276 { 277 onComplete: onComplete, 278 asynchronous: true, 279 evalScripts: true 280 } 281 ); 282 } 283 } else if (index > 0) { 284 return function() { 285 self.options.onLazyLoad(preContainer, this); 286 self.options.afterLazyLoad(this); 287 } 288 } 289 return function() { 290 self.options.onLazyLoad(preContainer, this); 291 } 202 292 } 203 204 293 } rubricks_core/trunk/public/javascripts/spinelz/window.js
r1712 r1833 43 43 } 44 44 45 Window.zIndex = 1000;46 47 45 Window.modalIdList = new Array(); 48 46 … … 108 106 restriction: false, 109 107 endDrag: Prototype.emptyFunction, 110 endResize: Prototype.emptyFunction 108 endResize: Prototype.emptyFunction, 109 addButton: Prototype.emptyFunction, 110 endMaximize: Prototype.emptyFunction, 111 endMinimize: Prototype.emptyFunction, 112 endRevertMaximize: Prototype.emptyFunction, 113 endRevertMinimize: Prototype.emptyFunction, 114 endClose: Prototype.emptyFunction 111 115 }, arguments[1] || {}); 112 116 … … 171 175 172 176 if (this.options.resize) { 173 var resTop = this.options.resizeY ? 6 : 0; 174 var resBottom = this.options.resizeY ? 6 : 0; 175 var resLeft = this.options.resizeX ? 6 : 0; 176 var resRight = this.options.resizeX ? 6 : 0; 177 new ResizeableWindowEx(this.element, 178 { 179 top: resTop, 180 bottom: resBottom, 181 left: resLeft, 182 right: resRight, 183 minWidth:this.options.minWidth, 184 minHeight:this.options.minHeight, 185 draw: this.setBodyHeight.bind(this), 186 resize: this.options.endResize 187 }); 177 this.enableResizing(); 188 178 } 189 179 }, … … 227 217 Event.observe(minButton, 'click', this.minimize.bindAsEventListener(this)); 228 218 } 229 219 220 if (this.options.addButton) { 221 var addButton = this.options.addButton; 222 if (addButton.constructor == Function) { 223 addButton(buttonHolder); 224 } else if (addButton.constructor == Array) { 225 var self = this; 226 var firstChild = buttonHolder.firstChild; 227 addButton.each(function(b) { 228 var button = Builder.node('div', {id: b.id, className: b.className}); 229 Event.observe(button, 'click', b.onclick.bindAsEventListener(self)); 230 if (b.first && firstChild) { 231 buttonHolder.insertBefore(button, firstChild); 232 } else { 233 buttonHolder.appendChild(button); 234 } 235 }); 236 } 237 } 230 238 }, 231 239 232 240 buildBody: function(contents) { 233 234 241 var bodyLeft = Builder.node('div', {className: Window.className.bodyLeft}); 235 242 this.classNames.addClassNames(bodyLeft, 'bodyLeft'); … … 295 302 var self = this; 296 303 var options = { 297 handle: this.dragHandleId,304 handle: this.dragHandleId, 298 305 startEffect: Prototype.emptyFunction, 299 endEffect: Prototype.emptyFunction, 300 endDrag: this.options.endDrag 306 endEffect: Prototype.emptyFunction, 307 endDrag: this.options.endDrag, 308 scroll: window 301 309 }; 302 310 303 311 if (this.options.restriction) { 304 options.snap = function(x, y) {312 options.snap = function(x, y) { 305 313 function constrain(n, lower, upper) { 306 314 if (n > upper) return upper; … … 310 318 311 319 var eDimensions = Element.getDimensions(self.element); 312 var pDimensions = Element.getDimensions(self.element.parentNode );320 var pDimensions = Element.getDimensions(self.element.parentNode); 313 321 var offset = Position.positionedOffset(self.element.parentNode); 314 322 var parentLeft = offset[0]; … … 328 336 } 329 337 } 330 331 338 new DraggableWindowEx(this.element, options); 332 339 }, … … 355 362 356 363 getZindex: function(zIndex) { 357 if (zIndex) { 358 if (isNaN(zIndex)) { 359 zIndex = Element.getMaxZindex() + 1; 360 } 361 } else { 362 zIndex = Window.zIndex; 363 } 364 Window.zIndex = zIndex + 1; 365 return zIndex; 364 return ZindexManager.getIndex(zIndex); 366 365 }, 367 366 … … 376 375 }, 377 376 378 close : function() {377 close: function() { 379 378 this.element.style.zIndex = -1; 380 379 this.maxZindex = -1; … … 391 390 } 392 391 } 393 if (this.options.close_callback) { 394 this.options.close_callback(this.element); 395 } 396 }, 397 398 minimize : function(event) { 392 this.options.endClose(this); 393 }, 394 395 minimize: function(event) { 399 396 Element.toggle(this.windowBody); 400 397 if (this.minFlag) { … … 402 399 this.minFlag = false; 403 400 this.setMax(); 404 405 401 } else { 406 402 var newStyle = {height:this.currentSize[1]} … … 411 407 this.element.style.top = this.currentPos[1]; 412 408 this.maxFlag = false; 413 this.minFlag = false; 409 this.minFlag = false; 410 this.options.endRevertMinimize(this); 414 411 } 415 412 } else { … … 420 417 this.setMin(); 421 418 this.minFlag = true; 419 this.options.endMinimize(this); 422 420 } 423 421 this.setFrameSize(); … … 444 442 for(var i = 0; i < this.nodeArray.length; i++) { 445 443 this.parent.appendChild(this.nodeArray[i]); 446 } 444 } 445 this.options.endRevertMaximize(this); 447 446 } 448 447 … … 465 464 this.setMax(); 466 465 this.maxFlag = true; 466 this.options.endMaximize(this); 467 467 } 468 468 this.setFrameSize(); … … 624 624 left += scrollLeft - pOffset[0]; 625 625 Element.setStyle(this.element, {left: left + 'px', top: top + 'px'}); 626 }, 627 628 enableResizing: function() { 629 var resTop = this.options.resizeY ? 6 : 0; 630 var resBottom = this.options.resizeY ? 6 : 0; 631 var resLeft = this.options.resizeX ? 6 : 0; 632 var resRight = this.options.resizeX ? 6 : 0; 633 this.resizeable = new ResizeableWindowEx(this.element, { 634 top: resTop, 635 bottom: resBottom, 636 left: resLeft, 637 right: resRight, 638 minWidth:this.options.minWidth, 639 minHeight:this.options.minHeight, 640 draw: this.setBodyHeight.bind(this), 641 resize: this.options.endResize 642 }); 643 }, 644 645 disableResizing: function() { 646 this.resizeable.destroy(); 626 647 } 627 648 } 628 649 650 651 // Copyright (c) 2005 spinelz.org (http://script.spinelz.org/) 652 // 653 // This code is substantially based on code from script.aculo.us which has the 654 // following copyright and permission notice 655 // 656 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 657 // 658 // Permission is hereby granted, free of charge, to any person obtaining 659 // a copy of this software and associated documentation files (the 660 // "Software"), to deal in the Software without restriction, including 661 // without limitation the rights to use, copy, modify, merge, publish, 662 // distribute, sublicense, and/or sell copies of the Software, and to 663 // permit persons to whom the Software is furnished to do so, subject to 664 // the following conditions: 665 // 666 // The above copyright notice and this permission notice shall be 667 // included in all copies or substantial portions of the Software. 668 // 669 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 670 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 671 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 672 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 673 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 674 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 675 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 629 676 630 677 var DraggableWindowEx = Class.create(); … … 651 698 this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); 652 699 653 var zIndex = Window.zIndex++;700 var zIndex = ZindexManager.getIndex(); 654 701 this.originalZ = zIndex; 655 702 this.options.zindex = zIndex; rubricks_core/trunk/public/javascripts/spinelz/window_resizeEx.js
r1563 r1833 1 1 // Copyright (c) 2005 spinelz.org (http://script.spinelz.org/) 2 // 3 // This code is substantially based on code from Thomas Fakes(http://craz8.com) 4 // which has the following copyright and permission notice 5 // 6 // Copyright (c) 2005 Thomas Fakes (http://craz8.com) 7 // 8 // This code is substantially based on code from script.aculo.us which has the 9 // following copyright and permission notice 10 // 11 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 12 // 3 13 // Permission is hereby granted, free of charge, to any person obtaining rubricks_core/trunk/public/javascripts/spinelz_lib/spinelz_util.js
r1563 r1833 468 468 } 469 469 } 470 471 472 /** 473 * ZindexManager 474 */ 475 var ZindexManager = { 476 zIndex: 1000, 477 478 getIndex: function(zIndex) { 479 if (zIndex) { 480 if (isNaN(zIndex)) { 481 zIndex = Element.getMaxZindex() + 1; 482 } else if (ZindexManager.zIndex > zIndex) { 483 zIndex = ZindexManager.zIndex; 484 } 485 } else { 486 zIndex = ZindexManager.zIndex; 487 } 488 ZindexManager.zIndex = zIndex + 1; 489 return zIndex; 490 } 491 } rubricks_core/trunk/public/stylesheets/spinelz/tabBox.css
r1563 r1833 1 .tabBox_tabBox { 2 position: relative; 3 } 4 1 5 .tabBox_panelContainer { 2 6 clear:left; … … 5 9 border-right:2px solid #919b9c; 6 10 border-bottom:2px solid #919b9c; 7 /* position: relative; */ 11 position: relative; 8 12 /* z-index:5; */ 9 13 } … … 11 15 .tabBox_tabContainer{ 12 16 height:28px; 17 } 18 19 .tabBox_tab { 20 float: left; 13 21 } 14 22 … … 22 30 margin-left:0px; 23 31 margin-right:0px; 24 /* position:relative; */ 32 position:relative; 25 33 bottom:-1px; 26 34 vertical-align:bottom; 35 overflow: hidden; 27 36 } 28 37 … … 84 93 /* z-index: 10; */ 85 94 } 95 96 .tabBox_tabTitle { 97 } 98 99 .tabBox_closeButton { 100 border: 0px; 101 overflow: hidden; 102 cursor:pointer; 103 font-size: 5px; 104 width: 12px; 105 height:12px; 106 background-image: url('../../images/spinelz/tabBox_close.gif'); 107 background-repeat: no-repeat; 108 background-position: 0 0; 109 position: relative; 110 top: -10px; 111 } rubricks_core/trunk/public/stylesheets/spinelz/window.css
r1239 r1833 46 46 47 47 .window_buttonHolder{ 48 width: 4 2px;48 width: 48px; 49 49 height: 12px; 50 50 position: absolute;
