www-thermferm/js/jquery-ui-1.10.3.custom.js

Tue, 08 Jul 2014 23:53:04 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 08 Jul 2014 23:53:04 +0200
changeset 97
4a9dbee41a6c
permissions
-rw-r--r--

Added initial set for the thermferm web interface

97
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*! jQuery UI - v1.10.3 - 2013-06-15
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * http://jqueryui.com
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Copyright 2013 jQuery Foundation and other contributors Licensed MIT */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 var uuid = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 runiqueId = /^ui-id-\d+$/;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 // $.ui might exist from components with no dependencies, e.g., $.ui.position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 $.ui = $.ui || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 $.extend( $.ui, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 keyCode: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 BACKSPACE: 8,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 COMMA: 188,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 DELETE: 46,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 DOWN: 40,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 END: 35,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 ENTER: 13,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 ESCAPE: 27,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 HOME: 36,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 LEFT: 37,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 NUMPAD_ADD: 107,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 NUMPAD_DECIMAL: 110,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 NUMPAD_DIVIDE: 111,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 NUMPAD_ENTER: 108,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 NUMPAD_MULTIPLY: 106,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 NUMPAD_SUBTRACT: 109,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 PAGE_DOWN: 34,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 PAGE_UP: 33,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 PERIOD: 190,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 RIGHT: 39,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 SPACE: 32,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 TAB: 9,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 UP: 38
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 // plugins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 $.fn.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 focus: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 return function( delay, fn ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 return typeof delay === "number" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 var elem = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 setTimeout(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 $( elem ).focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 if ( fn ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 fn.call( elem );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 }, delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 }) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 })( $.fn.focus ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 scrollParent: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 var scrollParent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 scrollParent = this.parents().filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 }).eq(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 scrollParent = this.parents().filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 }).eq(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 zIndex: function( zIndex ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 if ( zIndex !== undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 return this.css( "zIndex", zIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 if ( this.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 var elem = $( this[ 0 ] ), position, value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 while ( elem.length && elem[ 0 ] !== document ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 // Ignore z-index if position is set to a value where z-index is ignored by the browser
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 // This makes behavior of this function consistent across browsers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 // WebKit always returns auto if the element is positioned
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 position = elem.css( "position" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 if ( position === "absolute" || position === "relative" || position === "fixed" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 // IE returns 0 when zIndex is not specified
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 // other browsers return a string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 // we ignore the case of nested elements with an explicit value of 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 value = parseInt( elem.css( "zIndex" ), 10 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 if ( !isNaN( value ) && value !== 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 return value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 elem = elem.parent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 return 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 uniqueId: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 if ( !this.id ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 this.id = "ui-id-" + (++uuid);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 removeUniqueId: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 if ( runiqueId.test( this.id ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 $( this ).removeAttr( "id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 // selectors
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 function focusable( element, isTabIndexNotNaN ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 var map, mapName, img,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 nodeName = element.nodeName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 if ( "area" === nodeName ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 map = element.parentNode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 mapName = map.name;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 img = $( "img[usemap=#" + mapName + "]" )[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 return !!img && visible( img );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 return ( /input|select|textarea|button|object/.test( nodeName ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 !element.disabled :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 "a" === nodeName ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 element.href || isTabIndexNotNaN :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 isTabIndexNotNaN) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 // the element and all of its ancestors must be visible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 visible( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 function visible( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 return $.expr.filters.visible( element ) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 !$( element ).parents().addBack().filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 return $.css( this, "visibility" ) === "hidden";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 }).length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 $.extend( $.expr[ ":" ], {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 data: $.expr.createPseudo ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 $.expr.createPseudo(function( dataName ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 return function( elem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 return !!$.data( elem, dataName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 }) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 function( elem, i, match ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 return !!$.data( elem, match[ 3 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 focusable: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 tabbable: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 var tabIndex = $.attr( element, "tabindex" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 isTabIndexNaN = isNaN( tabIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 $.each( [ "Width", "Height" ], function( i, name ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 type = name.toLowerCase(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 orig = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 innerWidth: $.fn.innerWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 innerHeight: $.fn.innerHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 outerWidth: $.fn.outerWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 outerHeight: $.fn.outerHeight
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 function reduce( elem, size, border, margin ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 $.each( side, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 if ( border ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 if ( margin ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 return size;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 $.fn[ "inner" + name ] = function( size ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 if ( size === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 return orig[ "inner" + name ].call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 $( this ).css( type, reduce( this, size ) + "px" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 $.fn[ "outer" + name] = function( size, margin ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 if ( typeof size !== "number" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 return orig[ "outer" + name ].call( this, size );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 $( this).css( type, reduce( this, size, true, margin ) + "px" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 if ( !$.fn.addBack ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 $.fn.addBack = function( selector ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 return this.add( selector == null ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 this.prevObject : this.prevObject.filter( selector )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 $.fn.removeData = (function( removeData ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 return function( key ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 if ( arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 return removeData.call( this, $.camelCase( key ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 return removeData.call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 })( $.fn.removeData );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 // deprecated
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 $.support.selectstart = "onselectstart" in document.createElement( "div" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 $.fn.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 disableSelection: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 ".ui-disableSelection", function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 enableSelection: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 return this.unbind( ".ui-disableSelection" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 $.extend( $.ui, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 // $.ui.plugin is deprecated. Use $.widget() extensions instead.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 plugin: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 add: function( module, option, set ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 var i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 proto = $.ui[ module ].prototype;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 for ( i in set ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 proto.plugins[ i ] = proto.plugins[ i ] || [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 proto.plugins[ i ].push( [ option, set[ i ] ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 call: function( instance, name, args ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 var i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 set = instance.plugins[ name ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 for ( i = 0; i < set.length; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 if ( instance.options[ set[ i ][ 0 ] ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 set[ i ][ 1 ].apply( instance.element, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 // only used by resizable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 hasScroll: function( el, a ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 //If overflow is hidden, the element might have extra content, but the user wants to hide it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 if ( $( el ).css( "overflow" ) === "hidden") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 has = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 if ( el[ scroll ] > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 // TODO: determine which cases actually cause this to happen
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 // if the element doesn't have the scroll set, see if it's possible to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 // set the scroll
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 el[ scroll ] = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 has = ( el[ scroll ] > 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 el[ scroll ] = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 return has;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 var uuid = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 slice = Array.prototype.slice,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 _cleanData = $.cleanData;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 $.cleanData = function( elems ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 $( elem ).triggerHandler( "remove" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 // http://bugs.jquery.com/ticket/8235
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 } catch( e ) {}
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 _cleanData( elems );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 $.widget = function( name, base, prototype ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 var fullName, existingConstructor, constructor, basePrototype,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 // proxiedPrototype allows the provided prototype to remain unmodified
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 // so that it can be used as a mixin for multiple widgets (#8876)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 proxiedPrototype = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 namespace = name.split( "." )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 name = name.split( "." )[ 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 fullName = namespace + "-" + name;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 if ( !prototype ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 prototype = base;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 base = $.Widget;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 // create selector for plugin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 return !!$.data( elem, fullName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 $[ namespace ] = $[ namespace ] || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 existingConstructor = $[ namespace ][ name ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 constructor = $[ namespace ][ name ] = function( options, element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 // allow instantiation without "new" keyword
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 if ( !this._createWidget ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 return new constructor( options, element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 // allow instantiation without initializing for simple inheritance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 // must use "new" keyword (the code above always passes args)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 if ( arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 this._createWidget( options, element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 // extend with the existing constructor to carry over any static properties
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 $.extend( constructor, existingConstructor, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 version: prototype.version,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 // copy the object used to create the prototype in case we need to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 // redefine the widget later
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 _proto: $.extend( {}, prototype ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 // track widgets that inherit from this widget in case this widget is
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 // redefined after a widget inherits from it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 _childConstructors: []
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 basePrototype = new base();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 // we need to make the options hash a property directly on the new instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 // otherwise we'll modify the options hash on the prototype that we're
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 // inheriting from
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 basePrototype.options = $.widget.extend( {}, basePrototype.options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 $.each( prototype, function( prop, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 if ( !$.isFunction( value ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 proxiedPrototype[ prop ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 proxiedPrototype[ prop ] = (function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 var _super = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 return base.prototype[ prop ].apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 _superApply = function( args ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 return base.prototype[ prop ].apply( this, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 return function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 var __super = this._super,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 __superApply = this._superApply,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 returnValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 this._super = _super;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 this._superApply = _superApply;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 returnValue = value.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 this._super = __super;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 this._superApply = __superApply;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 return returnValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 })();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 constructor.prototype = $.widget.extend( basePrototype, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 // TODO: remove support for widgetEventPrefix
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 // always use the name + a colon as the prefix, e.g., draggable:start
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 // don't prefix for widgets that aren't DOM-based
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 }, proxiedPrototype, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416 constructor: constructor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
417 namespace: namespace,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
418 widgetName: name,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 widgetFullName: fullName
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 // If this widget is being redefined then we need to find all widgets that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 // are inheriting from it and redefine all of them so that they inherit from
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 // the new version of this widget. We're essentially trying to replace one
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 // level in the prototype chain.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 if ( existingConstructor ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 $.each( existingConstructor._childConstructors, function( i, child ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 var childPrototype = child.prototype;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 // redefine the child widget using the same prototype that was
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 // originally used, but inherit from the new version of the base
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 // remove the list of existing child constructors from the old constructor
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 // so the old child constructors can be garbage collected
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 delete existingConstructor._childConstructors;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 base._childConstructors.push( constructor );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 $.widget.bridge( name, constructor );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 $.widget.extend = function( target ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 var input = slice.call( arguments, 1 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 inputIndex = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 inputLength = input.length,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 key,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 for ( ; inputIndex < inputLength; inputIndex++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 for ( key in input[ inputIndex ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 value = input[ inputIndex ][ key ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 // Clone objects
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 if ( $.isPlainObject( value ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 target[ key ] = $.isPlainObject( target[ key ] ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 $.widget.extend( {}, target[ key ], value ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 // Don't extend strings, arrays, etc. with objects
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 $.widget.extend( {}, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 // Copy everything else by reference
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 target[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 return target;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 $.widget.bridge = function( name, object ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 var fullName = object.prototype.widgetFullName || name;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 $.fn[ name ] = function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 var isMethodCall = typeof options === "string",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 args = slice.call( arguments, 1 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 returnValue = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 // allow multiple hashes to be passed on init
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 options = !isMethodCall && args.length ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 $.widget.extend.apply( null, [ options ].concat(args) ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 if ( isMethodCall ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 var methodValue,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 instance = $.data( this, fullName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 if ( !instance ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 return $.error( "cannot call methods on " + name + " prior to initialization; " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 "attempted to call method '" + options + "'" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 return $.error( "no such method '" + options + "' for " + name + " widget instance" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 methodValue = instance[ options ].apply( instance, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 if ( methodValue !== instance && methodValue !== undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 returnValue = methodValue && methodValue.jquery ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 returnValue.pushStack( methodValue.get() ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 methodValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 var instance = $.data( this, fullName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 if ( instance ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 instance.option( options || {} )._init();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 $.data( this, fullName, new object( options, this ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 return returnValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 $.Widget = function( /* options, element */ ) {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 $.Widget._childConstructors = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 $.Widget.prototype = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 widgetName: "widget",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 widgetEventPrefix: "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 defaultElement: "<div>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 disabled: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 create: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 _createWidget: function( options, element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 element = $( element || this.defaultElement || this )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 this.element = $( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 this.uuid = uuid++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 this.eventNamespace = "." + this.widgetName + this.uuid;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 this.options = $.widget.extend( {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 this._getCreateOptions(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 this.bindings = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 this.hoverable = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 this.focusable = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 if ( element !== this ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 $.data( element, this.widgetFullName, this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 this._on( true, this.element, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 remove: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 if ( event.target === element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 this.destroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 this.document = $( element.style ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 // element within the document
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 element.ownerDocument :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 // element is window or document
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 element.document || element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 this._create();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 this._trigger( "create", null, this._getCreateEventData() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 this._init();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 _getCreateOptions: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565 _getCreateEventData: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 _create: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 _init: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 this._destroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 // we can probably remove the unbind calls in 2.0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 // all event bindings should go through this._on()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 .unbind( this.eventNamespace )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 // 1.9 BC for #7810
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 // TODO remove dual storage
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 .removeData( this.widgetName )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 .removeData( this.widgetFullName )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 // support: jquery <1.6.3
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 // http://bugs.jquery.com/ticket/9413
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 .removeData( $.camelCase( this.widgetFullName ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 this.widget()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 .unbind( this.eventNamespace )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 .removeAttr( "aria-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585 .removeClass(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 this.widgetFullName + "-disabled " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 "ui-state-disabled" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 // clean up events and states
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 this.bindings.unbind( this.eventNamespace );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 this.hoverable.removeClass( "ui-state-hover" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 this.focusable.removeClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 _destroy: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 widget: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 return this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 option: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 var options = key,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 parts,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 curOption,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 if ( arguments.length === 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 // don't return a reference to the internal hash
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 return $.widget.extend( {}, this.options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 if ( typeof key === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 options = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 parts = key.split( "." );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 key = parts.shift();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 if ( parts.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 for ( i = 0; i < parts.length - 1; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 curOption = curOption[ parts[ i ] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 key = parts.pop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 if ( value === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 return curOption[ key ] === undefined ? null : curOption[ key ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 curOption[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 if ( value === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 return this.options[ key ] === undefined ? null : this.options[ key ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 options[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 this._setOptions( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 _setOptions: function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 var key;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 for ( key in options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 this._setOption( key, options[ key ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 this.options[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 this.widget()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 .attr( "aria-disabled", value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 this.hoverable.removeClass( "ui-state-hover" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 this.focusable.removeClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 enable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 return this._setOption( "disabled", false );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 disable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 return this._setOption( "disabled", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 _on: function( suppressDisabledCheck, element, handlers ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 var delegateElement,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 instance = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 // no suppressDisabledCheck flag, shuffle arguments
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 if ( typeof suppressDisabledCheck !== "boolean" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 handlers = element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 element = suppressDisabledCheck;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 suppressDisabledCheck = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 // no element argument, shuffle and use this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 if ( !handlers ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 handlers = element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 element = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684 delegateElement = this.widget();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 // accept selectors, DOM elements
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 element = delegateElement = $( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 this.bindings = this.bindings.add( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 $.each( handlers, function( event, handler ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 function handlerProxy() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 // allow widgets to customize the disabled handling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 // - disabled as an array instead of boolean
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 // - disabled class as method for disabling individual parts
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 if ( !suppressDisabledCheck &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 ( instance.options.disabled === true ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 $( this ).hasClass( "ui-state-disabled" ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 return ( typeof handler === "string" ? instance[ handler ] : handler )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 .apply( instance, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 // copy the guid so direct unbinding works
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 if ( typeof handler !== "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 handlerProxy.guid = handler.guid =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 handler.guid || handlerProxy.guid || $.guid++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 var match = event.match( /^(\w+)\s*(.*)$/ ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 eventName = match[1] + instance.eventNamespace,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 selector = match[2];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 if ( selector ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 delegateElement.delegate( selector, eventName, handlerProxy );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 element.bind( eventName, handlerProxy );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 _off: function( element, eventName ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 element.unbind( eventName ).undelegate( eventName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 _delay: function( handler, delay ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 function handlerProxy() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 return ( typeof handler === "string" ? instance[ handler ] : handler )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 .apply( instance, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 var instance = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 return setTimeout( handlerProxy, delay || 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 _hoverable: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737 this.hoverable = this.hoverable.add( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738 this._on( element, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 mouseenter: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 $( event.currentTarget ).addClass( "ui-state-hover" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 mouseleave: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 $( event.currentTarget ).removeClass( "ui-state-hover" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 _focusable: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 this.focusable = this.focusable.add( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 this._on( element, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 focusin: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 $( event.currentTarget ).addClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 focusout: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 $( event.currentTarget ).removeClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 _trigger: function( type, event, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 var prop, orig,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 callback = this.options[ type ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 data = data || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 event = $.Event( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 event.type = ( type === this.widgetEventPrefix ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 type :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 this.widgetEventPrefix + type ).toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 // the original event may come from any element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 // so we need to reset the target on the new event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 event.target = this.element[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 // copy original event properties over to the new event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 orig = event.originalEvent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 if ( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 for ( prop in orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 if ( !( prop in event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 event[ prop ] = orig[ prop ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783 this.element.trigger( event, data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 return !( $.isFunction( callback ) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785 callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
786 event.isDefaultPrevented() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
788 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
789
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 if ( typeof options === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 options = { effect: options };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 var hasOptions,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 effectName = !options ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 method :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 options === true || typeof options === "number" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 defaultEffect :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 options.effect || defaultEffect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 options = options || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 if ( typeof options === "number" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 options = { duration: options };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 hasOptions = !$.isEmptyObject( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 options.complete = callback;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 if ( options.delay ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808 element.delay( options.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 element[ method ]( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 } else if ( effectName !== method && element[ effectName ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 element[ effectName ]( options.duration, options.easing, callback );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 element.queue(function( next ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 $( this )[ method ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 if ( callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818 callback.call( element[ 0 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 next();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
826 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 var mouseHandled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 $( document ).mouseup( function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 mouseHandled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 $.widget("ui.mouse", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
836 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 cancel: "input,textarea,button,select,option",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838 distance: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 delay: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
840 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841 _mouseInit: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
842 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
845 .bind("mousedown."+this.widgetName, function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
846 return that._mouseDown(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
847 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
848 .bind("click."+this.widgetName, function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
849 if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
850 $.removeData(event.target, that.widgetName + ".preventClickEvent");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
851 event.stopImmediatePropagation();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
852 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
853 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
854 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
855
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
856 this.started = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
857 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
858
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
859 // TODO: make sure destroying one instance of mouse doesn't mess with
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
860 // other instances of mouse
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 _mouseDestroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 this.element.unbind("."+this.widgetName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863 if ( this._mouseMoveDelegate ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
864 $(document)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
865 .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
866 .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
867 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
868 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
870 _mouseDown: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871 // don't let more than one widget handle mouseStart
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
872 if( mouseHandled ) { return; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
873
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
874 // we may have missed mouseup (out of window)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
875 (this._mouseStarted && this._mouseUp(event));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
877 this._mouseDownEvent = event;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
879 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
880 btnIsLeft = (event.which === 1),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
881 // event.target.nodeName works around a bug in IE 8 with
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882 // disabled inputs (#7620)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
883 elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
884 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
885 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
887
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
888 this.mouseDelayMet = !this.options.delay;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
889 if (!this.mouseDelayMet) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
890 this._mouseDelayTimer = setTimeout(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
891 that.mouseDelayMet = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
892 }, this.options.delay);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
893 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
894
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
896 this._mouseStarted = (this._mouseStart(event) !== false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
897 if (!this._mouseStarted) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
898 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
899 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
900 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
901 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
902
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903 // Click event may never have fired (Gecko & Opera)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905 $.removeData(event.target, this.widgetName + ".preventClickEvent");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 // these delegates are required to keep context
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 this._mouseMoveDelegate = function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910 return that._mouseMove(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 this._mouseUpDelegate = function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 return that._mouseUp(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 $(document)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921 mouseHandled = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 _mouseMove: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
926 // IE mouseup check - mouseup happened when mouse was out of window
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
927 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 return this._mouseUp(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
931 if (this._mouseStarted) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932 this._mouseDrag(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933 return event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
934 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
936 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 this._mouseStarted =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 (this._mouseStart(this._mouseDownEvent, event) !== false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 return !this._mouseStarted;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 _mouseUp: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946 $(document)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947 .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950 if (this._mouseStarted) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 this._mouseStarted = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 if (event.target === this._mouseDownEvent.target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 $.data(event.target, this.widgetName + ".preventClickEvent", true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 this._mouseStop(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 _mouseDistanceMet: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 return (Math.max(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 Math.abs(this._mouseDownEvent.pageX - event.pageX),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 Math.abs(this._mouseDownEvent.pageY - event.pageY)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 ) >= this.options.distance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 _mouseDelayMet: function(/* event */) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 return this.mouseDelayMet;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 // These are placeholder methods, to be overriden by extending plugin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 _mouseStart: function(/* event */) {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 _mouseDrag: function(/* event */) {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 _mouseStop: function(/* event */) {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 _mouseCapture: function(/* event */) { return true; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 $.ui = $.ui || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 var cachedScrollbarWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 max = Math.max,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 abs = Math.abs,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 round = Math.round,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 rhorizontal = /left|center|right/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992 rvertical = /top|center|bottom/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993 roffset = /[\+\-]\d+(\.[\d]+)?%?/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
994 rposition = /^\w+/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
995 rpercent = /%$/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 _position = $.fn.position;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 function getOffsets( offsets, width, height ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 function parseCss( element, property ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 return parseInt( $.css( element, property ), 10 ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 function getDimensions( elem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010 var raw = elem[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 if ( raw.nodeType === 9 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013 width: elem.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 height: elem.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015 offset: { top: 0, left: 0 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1018 if ( $.isWindow( raw ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1020 width: elem.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 height: elem.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1022 offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1023 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025 if ( raw.preventDefault ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027 width: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028 height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 offset: { top: raw.pageY, left: raw.pageX }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1033 width: elem.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1034 height: elem.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 offset: elem.offset()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1036 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1037 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1038
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1039 $.position = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 scrollbarWidth: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 if ( cachedScrollbarWidth !== undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1042 return cachedScrollbarWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1043 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 var w1, w2,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1045 div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1046 innerDiv = div.children()[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 $( "body" ).append( div );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 w1 = innerDiv.offsetWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1050 div.css( "overflow", "scroll" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1051
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 w2 = innerDiv.offsetWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 if ( w1 === w2 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 w2 = div[0].clientWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1057
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058 div.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1059
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1060 return (cachedScrollbarWidth = w1 - w2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1061 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 getScrollInfo: function( within ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063 var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1064 overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065 hasOverflowX = overflowX === "scroll" ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1066 ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067 hasOverflowY = overflowY === "scroll" ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1068 ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070 width: hasOverflowY ? $.position.scrollbarWidth() : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1071 height: hasOverflowX ? $.position.scrollbarWidth() : 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1072 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 getWithinInfo: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 var withinElement = $( element || window ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 isWindow = $.isWindow( withinElement[0] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1077 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1078 element: withinElement,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 isWindow: isWindow,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 offset: withinElement.offset() || { left: 0, top: 0 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 scrollLeft: withinElement.scrollLeft(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1082 scrollTop: withinElement.scrollTop(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1083 width: isWindow ? withinElement.width() : withinElement.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1084 height: isWindow ? withinElement.height() : withinElement.outerHeight()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1085 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1086 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1087 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1088
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1089 $.fn.position = function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1090 if ( !options || !options.of ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1091 return _position.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1092 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1094 // make a copy, we don't want to modify arguments
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 options = $.extend( {}, options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1096
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1097 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1098 target = $( options.of ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1099 within = $.position.getWithinInfo( options.within ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1100 scrollInfo = $.position.getScrollInfo( within ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 collision = ( options.collision || "flip" ).split( " " ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1102 offsets = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1104 dimensions = getDimensions( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 if ( target[0].preventDefault ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1106 // force left top to allow flipping
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1107 options.at = "left top";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1108 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1109 targetWidth = dimensions.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1110 targetHeight = dimensions.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1111 targetOffset = dimensions.offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1112 // clone to reuse original targetOffset later
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1113 basePosition = $.extend( {}, targetOffset );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1114
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1115 // force my and at to have valid horizontal and vertical positions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 // if a value is missing or invalid, it will be converted to center
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1117 $.each( [ "my", "at" ], function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 var pos = ( options[ this ] || "" ).split( " " ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119 horizontalOffset,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 verticalOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 if ( pos.length === 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 pos = rhorizontal.test( pos[ 0 ] ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124 pos.concat( [ "center" ] ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1125 rvertical.test( pos[ 0 ] ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1126 [ "center" ].concat( pos ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1127 [ "center", "center" ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1128 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1129 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1130 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1131
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1132 // calculate offsets
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1133 horizontalOffset = roffset.exec( pos[ 0 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1134 verticalOffset = roffset.exec( pos[ 1 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1135 offsets[ this ] = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1136 horizontalOffset ? horizontalOffset[ 0 ] : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1137 verticalOffset ? verticalOffset[ 0 ] : 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1138 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1139
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1140 // reduce to just the positions without the offsets
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1141 options[ this ] = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1142 rposition.exec( pos[ 0 ] )[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1143 rposition.exec( pos[ 1 ] )[ 0 ]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1144 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1145 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1146
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1147 // normalize collision option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1148 if ( collision.length === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1149 collision[ 1 ] = collision[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1150 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1151
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1152 if ( options.at[ 0 ] === "right" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1153 basePosition.left += targetWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1154 } else if ( options.at[ 0 ] === "center" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1155 basePosition.left += targetWidth / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1156 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1157
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1158 if ( options.at[ 1 ] === "bottom" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1159 basePosition.top += targetHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1160 } else if ( options.at[ 1 ] === "center" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1161 basePosition.top += targetHeight / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1162 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1163
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1164 atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1165 basePosition.left += atOffset[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1166 basePosition.top += atOffset[ 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1167
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1168 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1169 var collisionPosition, using,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1170 elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1171 elemWidth = elem.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1172 elemHeight = elem.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1173 marginLeft = parseCss( this, "marginLeft" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1174 marginTop = parseCss( this, "marginTop" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1175 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1176 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1177 position = $.extend( {}, basePosition ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1178 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1179
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1180 if ( options.my[ 0 ] === "right" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1181 position.left -= elemWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1182 } else if ( options.my[ 0 ] === "center" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1183 position.left -= elemWidth / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1184 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1185
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1186 if ( options.my[ 1 ] === "bottom" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1187 position.top -= elemHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1188 } else if ( options.my[ 1 ] === "center" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1189 position.top -= elemHeight / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1190 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1191
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1192 position.left += myOffset[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1193 position.top += myOffset[ 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1194
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1195 // if the browser doesn't support fractions, then round for consistent results
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1196 if ( !$.support.offsetFractions ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1197 position.left = round( position.left );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1198 position.top = round( position.top );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1199 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1200
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1201 collisionPosition = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1202 marginLeft: marginLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1203 marginTop: marginTop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1204 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1206 $.each( [ "left", "top" ], function( i, dir ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1207 if ( $.ui.position[ collision[ i ] ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1208 $.ui.position[ collision[ i ] ][ dir ]( position, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1209 targetWidth: targetWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210 targetHeight: targetHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1211 elemWidth: elemWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1212 elemHeight: elemHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1213 collisionPosition: collisionPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1214 collisionWidth: collisionWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1215 collisionHeight: collisionHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1216 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1217 my: options.my,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1218 at: options.at,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1219 within: within,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1220 elem : elem
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1221 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1222 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1223 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1224
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1225 if ( options.using ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1226 // adds feedback as second argument to using callback, if present
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1227 using = function( props ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1228 var left = targetOffset.left - position.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1229 right = left + targetWidth - elemWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1230 top = targetOffset.top - position.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1231 bottom = top + targetHeight - elemHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1232 feedback = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1233 target: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1234 element: target,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1235 left: targetOffset.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1236 top: targetOffset.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1237 width: targetWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1238 height: targetHeight
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1239 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1240 element: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1241 element: elem,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1242 left: position.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1243 top: position.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1244 width: elemWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1245 height: elemHeight
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1246 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1247 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1248 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1249 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1250 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1251 feedback.horizontal = "center";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1252 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1253 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1254 feedback.vertical = "middle";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1255 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1256 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1257 feedback.important = "horizontal";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1258 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1259 feedback.important = "vertical";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1260 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1261 options.using.call( this, props, feedback );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1262 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1263 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1264
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1265 elem.offset( $.extend( position, { using: using } ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1266 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1267 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1268
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1269 $.ui.position = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1270 fit: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1271 left: function( position, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1272 var within = data.within,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1273 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1274 outerWidth = within.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1275 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1276 overLeft = withinOffset - collisionPosLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1277 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1278 newOverRight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1279
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1280 // element is wider than within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1281 if ( data.collisionWidth > outerWidth ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1282 // element is initially over the left side of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1283 if ( overLeft > 0 && overRight <= 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1284 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1285 position.left += overLeft - newOverRight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1286 // element is initially over right side of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1287 } else if ( overRight > 0 && overLeft <= 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1288 position.left = withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1289 // element is initially over both left and right sides of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1290 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1291 if ( overLeft > overRight ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1292 position.left = withinOffset + outerWidth - data.collisionWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1293 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1294 position.left = withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1295 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1296 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1297 // too far left -> align with left edge
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1298 } else if ( overLeft > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1299 position.left += overLeft;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1300 // too far right -> align with right edge
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1301 } else if ( overRight > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1302 position.left -= overRight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1303 // adjust based on position and margin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1304 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1305 position.left = max( position.left - collisionPosLeft, position.left );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1306 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1307 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1308 top: function( position, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1309 var within = data.within,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1310 withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1311 outerHeight = data.within.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1312 collisionPosTop = position.top - data.collisionPosition.marginTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1313 overTop = withinOffset - collisionPosTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1314 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1315 newOverBottom;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1316
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1317 // element is taller than within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1318 if ( data.collisionHeight > outerHeight ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1319 // element is initially over the top of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1320 if ( overTop > 0 && overBottom <= 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1321 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1322 position.top += overTop - newOverBottom;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1323 // element is initially over bottom of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1324 } else if ( overBottom > 0 && overTop <= 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1325 position.top = withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1326 // element is initially over both top and bottom of within
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1327 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1328 if ( overTop > overBottom ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1329 position.top = withinOffset + outerHeight - data.collisionHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1330 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1331 position.top = withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1332 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1333 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1334 // too far up -> align with top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1335 } else if ( overTop > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1336 position.top += overTop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1337 // too far down -> align with bottom edge
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1338 } else if ( overBottom > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1339 position.top -= overBottom;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1340 // adjust based on position and margin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1341 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1342 position.top = max( position.top - collisionPosTop, position.top );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1343 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1344 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1345 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1346 flip: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1347 left: function( position, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1348 var within = data.within,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1349 withinOffset = within.offset.left + within.scrollLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1350 outerWidth = within.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1351 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1352 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1353 overLeft = collisionPosLeft - offsetLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1354 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1355 myOffset = data.my[ 0 ] === "left" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1356 -data.elemWidth :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1357 data.my[ 0 ] === "right" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1358 data.elemWidth :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1359 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1360 atOffset = data.at[ 0 ] === "left" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1361 data.targetWidth :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1362 data.at[ 0 ] === "right" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1363 -data.targetWidth :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1364 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1365 offset = -2 * data.offset[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1366 newOverRight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1367 newOverLeft;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1368
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1369 if ( overLeft < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1370 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1371 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1372 position.left += myOffset + atOffset + offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1373 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1374 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1375 else if ( overRight > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1376 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1377 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1378 position.left += myOffset + atOffset + offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1379 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1380 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1381 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1382 top: function( position, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1383 var within = data.within,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1384 withinOffset = within.offset.top + within.scrollTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1385 outerHeight = within.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1386 offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1387 collisionPosTop = position.top - data.collisionPosition.marginTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1388 overTop = collisionPosTop - offsetTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1389 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1390 top = data.my[ 1 ] === "top",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1391 myOffset = top ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1392 -data.elemHeight :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1393 data.my[ 1 ] === "bottom" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1394 data.elemHeight :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1395 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1396 atOffset = data.at[ 1 ] === "top" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1397 data.targetHeight :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1398 data.at[ 1 ] === "bottom" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1399 -data.targetHeight :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1400 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1401 offset = -2 * data.offset[ 1 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1402 newOverTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1403 newOverBottom;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1404 if ( overTop < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1405 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1406 if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1407 position.top += myOffset + atOffset + offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1408 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1409 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1410 else if ( overBottom > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1411 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1412 if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1413 position.top += myOffset + atOffset + offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1414 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1415 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1416 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1417 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1418 flipfit: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1419 left: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1420 $.ui.position.flip.left.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1421 $.ui.position.fit.left.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1422 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1423 top: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1424 $.ui.position.flip.top.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1425 $.ui.position.fit.top.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1426 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1427 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1428 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1429
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1430 // fraction support test
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1431 (function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1432 var testElement, testElementParent, testElementStyle, offsetLeft, i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1433 body = document.getElementsByTagName( "body" )[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1434 div = document.createElement( "div" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1435
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1436 //Create a "fake body" for testing based on method used in jQuery.support
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1437 testElement = document.createElement( body ? "div" : "body" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1438 testElementStyle = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1439 visibility: "hidden",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1440 width: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1441 height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1442 border: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1443 margin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1444 background: "none"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1445 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1446 if ( body ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1447 $.extend( testElementStyle, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1448 position: "absolute",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1449 left: "-1000px",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1450 top: "-1000px"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1451 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1452 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1453 for ( i in testElementStyle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1454 testElement.style[ i ] = testElementStyle[ i ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1455 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1456 testElement.appendChild( div );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1457 testElementParent = body || document.documentElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1458 testElementParent.insertBefore( testElement, testElementParent.firstChild );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1459
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1460 div.style.cssText = "position: absolute; left: 10.7432222px;";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1461
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1462 offsetLeft = $( div ).offset().left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1463 $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1464
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1465 testElement.innerHTML = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1466 testElementParent.removeChild( testElement );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1467 })();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1468
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1469 }( jQuery ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1470 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1471
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1472 $.widget("ui.draggable", $.ui.mouse, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1473 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1474 widgetEventPrefix: "drag",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1475 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1476 addClasses: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1477 appendTo: "parent",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1478 axis: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1479 connectToSortable: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1480 containment: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1481 cursor: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1482 cursorAt: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1483 grid: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1484 handle: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1485 helper: "original",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1486 iframeFix: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1487 opacity: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1488 refreshPositions: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1489 revert: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1490 revertDuration: 500,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1491 scope: "default",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1492 scroll: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1493 scrollSensitivity: 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1494 scrollSpeed: 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1495 snap: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1496 snapMode: "both",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1497 snapTolerance: 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1498 stack: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1499 zIndex: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1500
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1501 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1502 drag: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1503 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1504 stop: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1505 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1506 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1507
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1508 if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1509 this.element[0].style.position = "relative";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1510 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1511 if (this.options.addClasses){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1512 this.element.addClass("ui-draggable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1513 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1514 if (this.options.disabled){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1515 this.element.addClass("ui-draggable-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1516 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1517
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1518 this._mouseInit();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1519
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1520 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1521
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1522 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1523 this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1524 this._mouseDestroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1525 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1526
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1527 _mouseCapture: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1528
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1529 var o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1530
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1531 // among others, prevent a drag on a resizable-handle
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1532 if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1533 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1534 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1536 //Quit if we're not on a valid handle
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1537 this.handle = this._getHandle(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1538 if (!this.handle) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1539 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1540 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1541
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1542 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1543 $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1544 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1545 width: this.offsetWidth+"px", height: this.offsetHeight+"px",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1546 position: "absolute", opacity: "0.001", zIndex: 1000
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1547 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1548 .css($(this).offset())
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1549 .appendTo("body");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1550 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1551
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1552 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1553
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1554 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1555
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1556 _mouseStart: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1557
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1558 var o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1560 //Create and append the visible helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1561 this.helper = this._createHelper(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1562
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1563 this.helper.addClass("ui-draggable-dragging");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1564
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1565 //Cache the helper size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1566 this._cacheHelperProportions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1567
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1568 //If ddmanager is used for droppables, set the global draggable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1569 if($.ui.ddmanager) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1570 $.ui.ddmanager.current = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1571 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1572
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1573 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1574 * - Position generation -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1575 * This block generates everything position related - it's the core of draggables.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1576 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1577
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1578 //Cache the margins of the original element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1579 this._cacheMargins();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1580
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1581 //Store the helper's css position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1582 this.cssPosition = this.helper.css( "position" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1583 this.scrollParent = this.helper.scrollParent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1584 this.offsetParent = this.helper.offsetParent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1585 this.offsetParentCssPosition = this.offsetParent.css( "position" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1586
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1587 //The element's absolute position on the page minus margins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1588 this.offset = this.positionAbs = this.element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1589 this.offset = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1590 top: this.offset.top - this.margins.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1591 left: this.offset.left - this.margins.left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1592 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1593
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1594 //Reset scroll cache
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1595 this.offset.scroll = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1596
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1597 $.extend(this.offset, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1598 click: { //Where the click happened, relative to the element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1599 left: event.pageX - this.offset.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1600 top: event.pageY - this.offset.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1601 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1602 parent: this._getParentOffset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1603 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1604 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1605
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1606 //Generate the original position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1607 this.originalPosition = this.position = this._generatePosition(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1608 this.originalPageX = event.pageX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1609 this.originalPageY = event.pageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1611 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1612 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1613
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1614 //Set a containment if given in the options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1615 this._setContainment();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1616
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1617 //Trigger event + callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1618 if(this._trigger("start", event) === false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1619 this._clear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1620 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1621 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1622
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1623 //Recache the helper size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1624 this._cacheHelperProportions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1625
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1626 //Prepare the droppable offsets
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1627 if ($.ui.ddmanager && !o.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1628 $.ui.ddmanager.prepareOffsets(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1629 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1630
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1631
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1632 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1634 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1635 if ( $.ui.ddmanager ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1636 $.ui.ddmanager.dragStart(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1637 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1638
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1639 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1640 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1641
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1642 _mouseDrag: function(event, noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1643 // reset any necessary cached properties (see #5009)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1644 if ( this.offsetParentCssPosition === "fixed" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1645 this.offset.parent = this._getParentOffset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1646 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1647
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1648 //Compute the helpers position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1649 this.position = this._generatePosition(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1650 this.positionAbs = this._convertPositionTo("absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1651
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1652 //Call plugins and callbacks and use the resulting position if something is returned
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1653 if (!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1654 var ui = this._uiHash();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1655 if(this._trigger("drag", event, ui) === false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1656 this._mouseUp({});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1657 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1658 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1659 this.position = ui.position;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1660 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1661
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1662 if(!this.options.axis || this.options.axis !== "y") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1663 this.helper[0].style.left = this.position.left+"px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1664 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1665 if(!this.options.axis || this.options.axis !== "x") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1666 this.helper[0].style.top = this.position.top+"px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1667 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1668 if($.ui.ddmanager) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1669 $.ui.ddmanager.drag(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1670 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1671
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1672 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1673 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1674
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1675 _mouseStop: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1676
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1677 //If we are using droppables, inform the manager about the drop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1678 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1679 dropped = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1680 if ($.ui.ddmanager && !this.options.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1681 dropped = $.ui.ddmanager.drop(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1682 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1683
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1684 //if a drop comes from outside (a sortable)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1685 if(this.dropped) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1686 dropped = this.dropped;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1687 this.dropped = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1688 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1689
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1690 //if the original element is no longer in the DOM don't bother to continue (see #8269)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1691 if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1692 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1693 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1694
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1695 if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1696 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1697 if(that._trigger("stop", event) !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1698 that._clear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1699 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1700 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1701 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1702 if(this._trigger("stop", event) !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1703 this._clear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1704 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1705 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1706
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1707 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1708 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1709
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1710 _mouseUp: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1711 //Remove frame helpers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1712 $("div.ui-draggable-iframeFix").each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1713 this.parentNode.removeChild(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1714 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1715
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1716 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1717 if( $.ui.ddmanager ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1718 $.ui.ddmanager.dragStop(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1719 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1720
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1721 return $.ui.mouse.prototype._mouseUp.call(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1722 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1723
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1724 cancel: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1725
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1726 if(this.helper.is(".ui-draggable-dragging")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1727 this._mouseUp({});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1728 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1729 this._clear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1730 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1731
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1732 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1733
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1734 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1735
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1736 _getHandle: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1737 return this.options.handle ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1738 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1739 true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1740 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1741
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1742 _createHelper: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1743
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1744 var o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1745 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1746
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1747 if(!helper.parents("body").length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1748 helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1749 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1750
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1751 if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1752 helper.css("position", "absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1753 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1754
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1755 return helper;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1756
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1757 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1758
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1759 _adjustOffsetFromHelper: function(obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1760 if (typeof obj === "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1761 obj = obj.split(" ");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1762 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1763 if ($.isArray(obj)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1764 obj = {left: +obj[0], top: +obj[1] || 0};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1765 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1766 if ("left" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1767 this.offset.click.left = obj.left + this.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1768 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1769 if ("right" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1770 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1771 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1772 if ("top" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1773 this.offset.click.top = obj.top + this.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1774 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1775 if ("bottom" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1776 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1777 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1778 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1779
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1780 _getParentOffset: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1781
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1782 //Get the offsetParent and cache its position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1783 var po = this.offsetParent.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1784
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1785 // This is a special case where we need to modify a offset calculated on start, since the following happened:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1786 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1787 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1788 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1789 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1790 po.left += this.scrollParent.scrollLeft();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1791 po.top += this.scrollParent.scrollTop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1792 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1794 //This needs to be actually done for all browsers, since pageX/pageY includes this information
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1795 //Ugly IE fix
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1796 if((this.offsetParent[0] === document.body) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1797 (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1798 po = { top: 0, left: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1799 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1800
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1801 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1802 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1803 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1804 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1805
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1806 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1807
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1808 _getRelativeOffset: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1809
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1810 if(this.cssPosition === "relative") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1811 var p = this.element.position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1812 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1813 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1814 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1815 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1816 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1817 return { top: 0, left: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1818 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1819
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1820 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1821
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1822 _cacheMargins: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1823 this.margins = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1824 left: (parseInt(this.element.css("marginLeft"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1825 top: (parseInt(this.element.css("marginTop"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1826 right: (parseInt(this.element.css("marginRight"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1827 bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1828 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1829 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1830
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1831 _cacheHelperProportions: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1832 this.helperProportions = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1833 width: this.helper.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1834 height: this.helper.outerHeight()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1835 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1836 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1837
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1838 _setContainment: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1839
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1840 var over, c, ce,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1841 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1842
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1843 if ( !o.containment ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1844 this.containment = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1845 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1846 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1847
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1848 if ( o.containment === "window" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1849 this.containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1850 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1851 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1852 $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1853 $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1854 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1855 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1856 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1857
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1858 if ( o.containment === "document") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1859 this.containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1860 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1861 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1862 $( document ).width() - this.helperProportions.width - this.margins.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1863 ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1864 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1865 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1866 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1867
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1868 if ( o.containment.constructor === Array ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1869 this.containment = o.containment;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1870 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1871 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1872
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1873 if ( o.containment === "parent" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1874 o.containment = this.helper[ 0 ].parentNode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1875 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1877 c = $( o.containment );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1878 ce = c[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1879
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1880 if( !ce ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1881 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1882 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1883
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1884 over = c.css( "overflow" ) !== "hidden";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1885
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1886 this.containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1887 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1888 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1889 ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1890 ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1891 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1892 this.relative_container = c;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1893 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1894
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1895 _convertPositionTo: function(d, pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1896
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1897 if(!pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1898 pos = this.position;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1899 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1900
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1901 var mod = d === "absolute" ? 1 : -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1902 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1903
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1904 //Cache the scroll
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1905 if (!this.offset.scroll) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1906 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1907 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1908
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1909 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1910 top: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1911 pos.top + // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1912 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1913 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1914 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1915 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1916 left: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1917 pos.left + // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1918 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1919 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1920 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1921 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1922 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1923
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1924 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1925
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1926 _generatePosition: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1927
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1928 var containment, co, top, left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1929 o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1930 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1931 pageX = event.pageX,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1932 pageY = event.pageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1933
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1934 //Cache the scroll
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1935 if (!this.offset.scroll) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1936 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1937 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1938
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1939 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1940 * - Position constraining -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1941 * Constrain the position to a mix of grid, containment.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1942 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1943
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1944 // If we are not dragging yet, we won't check for options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1945 if ( this.originalPosition ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1946 if ( this.containment ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1947 if ( this.relative_container ){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1948 co = this.relative_container.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1949 containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1950 this.containment[ 0 ] + co.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1951 this.containment[ 1 ] + co.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1952 this.containment[ 2 ] + co.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1953 this.containment[ 3 ] + co.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1954 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1955 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1956 else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1957 containment = this.containment;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1958 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1959
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1960 if(event.pageX - this.offset.click.left < containment[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1961 pageX = containment[0] + this.offset.click.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1962 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1963 if(event.pageY - this.offset.click.top < containment[1]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1964 pageY = containment[1] + this.offset.click.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1965 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1966 if(event.pageX - this.offset.click.left > containment[2]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1967 pageX = containment[2] + this.offset.click.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1968 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1969 if(event.pageY - this.offset.click.top > containment[3]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1970 pageY = containment[3] + this.offset.click.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1971 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1972 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1973
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1974 if(o.grid) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1975 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1976 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1977 pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1978
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1979 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1980 pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1981 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1982
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1983 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1984
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1985 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1986 top: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1987 pageY - // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1988 this.offset.click.top - // Click offset (relative to the element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1989 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1990 this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1991 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1992 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1993 left: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1994 pageX - // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1995 this.offset.click.left - // Click offset (relative to the element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1996 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1997 this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1998 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1999 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2000 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2001
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2002 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2003
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2004 _clear: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2005 this.helper.removeClass("ui-draggable-dragging");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2006 if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2007 this.helper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2008 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2009 this.helper = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2010 this.cancelHelperRemoval = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2011 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2012
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2013 // From now on bulk stuff - mainly helpers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2014
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2015 _trigger: function(type, event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2016 ui = ui || this._uiHash();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2017 $.ui.plugin.call(this, type, [event, ui]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2018 //The absolute position has to be recalculated after plugins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2019 if(type === "drag") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2020 this.positionAbs = this._convertPositionTo("absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2021 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2022 return $.Widget.prototype._trigger.call(this, type, event, ui);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2023 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2024
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2025 plugins: {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2026
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2027 _uiHash: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2028 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2029 helper: this.helper,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2030 position: this.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2031 originalPosition: this.originalPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2032 offset: this.positionAbs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2033 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2034 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2035
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2036 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2037
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2038 $.ui.plugin.add("draggable", "connectToSortable", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2039 start: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2040
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2041 var inst = $(this).data("ui-draggable"), o = inst.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2042 uiSortable = $.extend({}, ui, { item: inst.element });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2043 inst.sortables = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2044 $(o.connectToSortable).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2045 var sortable = $.data(this, "ui-sortable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2046 if (sortable && !sortable.options.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2047 inst.sortables.push({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2048 instance: sortable,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2049 shouldRevert: sortable.options.revert
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2050 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2051 sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2052 sortable._trigger("activate", event, uiSortable);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2053 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2054 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2055
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2056 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2057 stop: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2058
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2059 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2060 var inst = $(this).data("ui-draggable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2061 uiSortable = $.extend({}, ui, { item: inst.element });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2062
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2063 $.each(inst.sortables, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2064 if(this.instance.isOver) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2065
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2066 this.instance.isOver = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2067
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2068 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2069 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2070
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2071 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2072 if(this.shouldRevert) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2073 this.instance.options.revert = this.shouldRevert;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2074 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2075
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2076 //Trigger the stop of the sortable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2077 this.instance._mouseStop(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2078
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2079 this.instance.options.helper = this.instance.options._helper;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2080
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2081 //If the helper has been the original item, restore properties in the sortable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2082 if(inst.options.helper === "original") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2083 this.instance.currentItem.css({ top: "auto", left: "auto" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2084 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2085
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2086 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2087 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2088 this.instance._trigger("deactivate", event, uiSortable);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2089 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2090
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2091 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2092
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2093 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2094 drag: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2095
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2096 var inst = $(this).data("ui-draggable"), that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2097
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2098 $.each(inst.sortables, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2099
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2100 var innermostIntersecting = false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2101 thisSortable = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2102
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2103 //Copy over some variables to allow calling the sortable's native _intersectsWith
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2104 this.instance.positionAbs = inst.positionAbs;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2105 this.instance.helperProportions = inst.helperProportions;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2106 this.instance.offset.click = inst.offset.click;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2107
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2108 if(this.instance._intersectsWith(this.instance.containerCache)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2109 innermostIntersecting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2110 $.each(inst.sortables, function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2111 this.instance.positionAbs = inst.positionAbs;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2112 this.instance.helperProportions = inst.helperProportions;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2113 this.instance.offset.click = inst.offset.click;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2114 if (this !== thisSortable &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2115 this.instance._intersectsWith(this.instance.containerCache) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2116 $.contains(thisSortable.instance.element[0], this.instance.element[0])
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2117 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2118 innermostIntersecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2119 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2120 return innermostIntersecting;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2121 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2122 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2123
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2124
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2125 if(innermostIntersecting) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2126 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2127 if(!this.instance.isOver) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2128
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2129 this.instance.isOver = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2130 //Now we fake the start of dragging for the sortable instance,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2131 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2132 //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2133 this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2134 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2135 this.instance.options.helper = function() { return ui.helper[0]; };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2136
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2137 event.target = this.instance.currentItem[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2138 this.instance._mouseCapture(event, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2139 this.instance._mouseStart(event, true, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2140
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2141 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2142 this.instance.offset.click.top = inst.offset.click.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2143 this.instance.offset.click.left = inst.offset.click.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2144 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2145 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2146
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2147 inst._trigger("toSortable", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2148 inst.dropped = this.instance.element; //draggable revert needs that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2149 //hack so receive/update callbacks work (mostly)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2150 inst.currentItem = inst.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2151 this.instance.fromOutside = inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2152
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2153 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2154
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2155 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2156 if(this.instance.currentItem) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2157 this.instance._mouseDrag(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2159
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2160 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2161
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2162 //If it doesn't intersect with the sortable, and it intersected before,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2163 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2164 if(this.instance.isOver) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2166 this.instance.isOver = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2167 this.instance.cancelHelperRemoval = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2168
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2169 //Prevent reverting on this forced stop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2170 this.instance.options.revert = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2171
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2172 // The out event needs to be triggered independently
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2173 this.instance._trigger("out", event, this.instance._uiHash(this.instance));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2174
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2175 this.instance._mouseStop(event, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2176 this.instance.options.helper = this.instance.options._helper;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2177
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2178 //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2179 this.instance.currentItem.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2180 if(this.instance.placeholder) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2181 this.instance.placeholder.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2182 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2183
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2184 inst._trigger("fromSortable", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2185 inst.dropped = false; //draggable revert needs that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2186 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2187
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2188 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2189
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2190 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2191
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2192 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2193 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2194
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2195 $.ui.plugin.add("draggable", "cursor", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2196 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2197 var t = $("body"), o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2198 if (t.css("cursor")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2199 o._cursor = t.css("cursor");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2200 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2201 t.css("cursor", o.cursor);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2202 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2203 stop: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2204 var o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2205 if (o._cursor) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2206 $("body").css("cursor", o._cursor);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2207 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2208 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2209 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2210
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2211 $.ui.plugin.add("draggable", "opacity", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2212 start: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2213 var t = $(ui.helper), o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2214 if(t.css("opacity")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2215 o._opacity = t.css("opacity");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2216 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2217 t.css("opacity", o.opacity);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2218 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2219 stop: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2220 var o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2221 if(o._opacity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2222 $(ui.helper).css("opacity", o._opacity);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2223 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2224 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2225 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2226
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2227 $.ui.plugin.add("draggable", "scroll", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2228 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2229 var i = $(this).data("ui-draggable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2230 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2231 i.overflowOffset = i.scrollParent.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2232 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2233 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2234 drag: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2235
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2236 var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2237
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2238 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2239
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2240 if(!o.axis || o.axis !== "x") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2241 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2242 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2243 } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2244 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2245 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2246 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2247
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2248 if(!o.axis || o.axis !== "y") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2249 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2250 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2251 } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2252 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2253 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2254 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2255
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2256 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2257
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2258 if(!o.axis || o.axis !== "x") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2259 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2260 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2261 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2262 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2263 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2264 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2265
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2266 if(!o.axis || o.axis !== "y") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2267 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2268 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2269 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2270 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2271 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2272 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2273
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2274 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2275
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2276 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2277 $.ui.ddmanager.prepareOffsets(i, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2278 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2279
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2280 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2281 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2282
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2283 $.ui.plugin.add("draggable", "snap", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2284 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2285
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2286 var i = $(this).data("ui-draggable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2287 o = i.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2288
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2289 i.snapElements = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2290
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2291 $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2292 var $t = $(this),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2293 $o = $t.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2294 if(this !== i.element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2295 i.snapElements.push({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2296 item: this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2297 width: $t.outerWidth(), height: $t.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2298 top: $o.top, left: $o.left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2299 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2300 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2301 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2302
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2303 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2304 drag: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2305
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2306 var ts, bs, ls, rs, l, r, t, b, i, first,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2307 inst = $(this).data("ui-draggable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2308 o = inst.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2309 d = o.snapTolerance,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2310 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2311 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2312
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2313 for (i = inst.snapElements.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2314
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2315 l = inst.snapElements[i].left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2316 r = l + inst.snapElements[i].width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2317 t = inst.snapElements[i].top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2318 b = t + inst.snapElements[i].height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2319
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2320 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2321 if(inst.snapElements[i].snapping) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2322 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2323 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2324 inst.snapElements[i].snapping = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2325 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2326 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2327
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2328 if(o.snapMode !== "inner") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2329 ts = Math.abs(t - y2) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2330 bs = Math.abs(b - y1) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2331 ls = Math.abs(l - x2) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2332 rs = Math.abs(r - x1) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2333 if(ts) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2334 ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2335 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2336 if(bs) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2337 ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2338 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2339 if(ls) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2340 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2341 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2342 if(rs) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2343 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2344 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2345 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2346
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2347 first = (ts || bs || ls || rs);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2348
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2349 if(o.snapMode !== "outer") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2350 ts = Math.abs(t - y1) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2351 bs = Math.abs(b - y2) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2352 ls = Math.abs(l - x1) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2353 rs = Math.abs(r - x2) <= d;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2354 if(ts) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2355 ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2356 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2357 if(bs) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2358 ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2359 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2360 if(ls) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2361 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2362 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2363 if(rs) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2364 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2365 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2366 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2367
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2368 if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2369 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2370 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2371 inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2372
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2373 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2374
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2375 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2376 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2377
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2378 $.ui.plugin.add("draggable", "stack", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2379 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2380 var min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2381 o = this.data("ui-draggable").options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2382 group = $.makeArray($(o.stack)).sort(function(a,b) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2383 return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2384 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2386 if (!group.length) { return; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2387
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2388 min = parseInt($(group[0]).css("zIndex"), 10) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2389 $(group).each(function(i) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2390 $(this).css("zIndex", min + i);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2391 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2392 this.css("zIndex", (min + group.length));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2393 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2394 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2395
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2396 $.ui.plugin.add("draggable", "zIndex", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2397 start: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2398 var t = $(ui.helper), o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2399 if(t.css("zIndex")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2400 o._zIndex = t.css("zIndex");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2401 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2402 t.css("zIndex", o.zIndex);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2403 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2404 stop: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2405 var o = $(this).data("ui-draggable").options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2406 if(o._zIndex) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2407 $(ui.helper).css("zIndex", o._zIndex);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2408 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2409 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2410 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2411
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2412 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2413 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2414
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2415 function isOverAxis( x, reference, size ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2416 return ( x > reference ) && ( x < ( reference + size ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2417 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2418
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2419 $.widget("ui.droppable", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2420 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2421 widgetEventPrefix: "drop",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2422 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2423 accept: "*",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2424 activeClass: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2425 addClasses: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2426 greedy: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2427 hoverClass: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2428 scope: "default",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2429 tolerance: "intersect",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2430
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2431 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2432 activate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2433 deactivate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2434 drop: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2435 out: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2436 over: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2437 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2438 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2439
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2440 var o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2441 accept = o.accept;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2442
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2443 this.isover = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2444 this.isout = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2445
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2446 this.accept = $.isFunction(accept) ? accept : function(d) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2447 return d.is(accept);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2448 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2449
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2450 //Store the droppable's proportions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2451 this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2452
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2453 // Add the reference and positions to the manager
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2454 $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2455 $.ui.ddmanager.droppables[o.scope].push(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2456
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2457 (o.addClasses && this.element.addClass("ui-droppable"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2458
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2459 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2460
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2461 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2462 var i = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2463 drop = $.ui.ddmanager.droppables[this.options.scope];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2464
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2465 for ( ; i < drop.length; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2466 if ( drop[i] === this ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2467 drop.splice(i, 1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2468 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2469 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2470
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2471 this.element.removeClass("ui-droppable ui-droppable-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2472 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2473
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2474 _setOption: function(key, value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2475
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2476 if(key === "accept") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2477 this.accept = $.isFunction(value) ? value : function(d) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2478 return d.is(value);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2479 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2480 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2481 $.Widget.prototype._setOption.apply(this, arguments);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2482 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2483
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2484 _activate: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2485 var draggable = $.ui.ddmanager.current;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2486 if(this.options.activeClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2487 this.element.addClass(this.options.activeClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2489 if(draggable){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2490 this._trigger("activate", event, this.ui(draggable));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2491 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2492 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2493
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2494 _deactivate: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2495 var draggable = $.ui.ddmanager.current;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2496 if(this.options.activeClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2497 this.element.removeClass(this.options.activeClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2498 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2499 if(draggable){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2500 this._trigger("deactivate", event, this.ui(draggable));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2501 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2502 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2503
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2504 _over: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2505
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2506 var draggable = $.ui.ddmanager.current;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2507
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2508 // Bail if draggable and droppable are same element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2509 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2510 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2511 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2512
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2513 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2514 if(this.options.hoverClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2515 this.element.addClass(this.options.hoverClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2516 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2517 this._trigger("over", event, this.ui(draggable));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2518 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2519
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2520 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2521
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2522 _out: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2523
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2524 var draggable = $.ui.ddmanager.current;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2525
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2526 // Bail if draggable and droppable are same element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2527 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2528 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2529 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2530
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2531 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2532 if(this.options.hoverClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2533 this.element.removeClass(this.options.hoverClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2534 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2535 this._trigger("out", event, this.ui(draggable));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2536 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2537
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2538 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2539
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2540 _drop: function(event,custom) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2541
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2542 var draggable = custom || $.ui.ddmanager.current,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2543 childrenIntersection = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2544
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2545 // Bail if draggable and droppable are same element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2546 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2547 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2548 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2549
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2550 this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2551 var inst = $.data(this, "ui-droppable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2552 if(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2553 inst.options.greedy &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2554 !inst.options.disabled &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2555 inst.options.scope === draggable.options.scope &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2556 inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2557 $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2558 ) { childrenIntersection = true; return false; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2559 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2560 if(childrenIntersection) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2561 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2562 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2563
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2564 if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2565 if(this.options.activeClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2566 this.element.removeClass(this.options.activeClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2567 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2568 if(this.options.hoverClass) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2569 this.element.removeClass(this.options.hoverClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2570 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2571 this._trigger("drop", event, this.ui(draggable));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2572 return this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2573 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2574
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2575 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2576
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2577 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2578
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2579 ui: function(c) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2580 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2581 draggable: (c.currentItem || c.element),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2582 helper: c.helper,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2583 position: c.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2584 offset: c.positionAbs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2585 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2586 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2587
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2588 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2589
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2590 $.ui.intersect = function(draggable, droppable, toleranceMode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2591
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2592 if (!droppable.offset) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2593 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2594 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2595
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2596 var draggableLeft, draggableTop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2597 x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2598 y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2599 l = droppable.offset.left, r = l + droppable.proportions.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2600 t = droppable.offset.top, b = t + droppable.proportions.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2601
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2602 switch (toleranceMode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2603 case "fit":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2604 return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2605 case "intersect":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2606 return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2607 x2 - (draggable.helperProportions.width / 2) < r && // Left Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2608 t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2609 y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2610 case "pointer":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2611 draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2612 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2613 return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2614 case "touch":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2615 return (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2616 (y1 >= t && y1 <= b) || // Top edge touching
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2617 (y2 >= t && y2 <= b) || // Bottom edge touching
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2618 (y1 < t && y2 > b) // Surrounded vertically
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2619 ) && (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2620 (x1 >= l && x1 <= r) || // Left edge touching
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2621 (x2 >= l && x2 <= r) || // Right edge touching
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2622 (x1 < l && x2 > r) // Surrounded horizontally
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2623 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2624 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2625 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2626 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2627
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2628 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2629
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2630 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2631 This manager tracks offsets of draggables and droppables
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2632 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2633 $.ui.ddmanager = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2634 current: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2635 droppables: { "default": [] },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2636 prepareOffsets: function(t, event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2638 var i, j,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2639 m = $.ui.ddmanager.droppables[t.options.scope] || [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2640 type = event ? event.type : null, // workaround for #2317
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2641 list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2642
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2643 droppablesLoop: for (i = 0; i < m.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2644
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2645 //No disabled and non-accepted
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2646 if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2647 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2648 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2649
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2650 // Filter out elements in the current dragged item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2651 for (j=0; j < list.length; j++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2652 if(list[j] === m[i].element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2653 m[i].proportions.height = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2654 continue droppablesLoop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2655 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2656 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2657
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2658 m[i].visible = m[i].element.css("display") !== "none";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2659 if(!m[i].visible) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2660 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2661 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2662
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2663 //Activate the droppable if used directly from draggables
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2664 if(type === "mousedown") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2665 m[i]._activate.call(m[i], event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2666 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2667
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2668 m[i].offset = m[i].element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2669 m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2670
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2671 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2672
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2673 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2674 drop: function(draggable, event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2675
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2676 var dropped = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2677 // Create a copy of the droppables in case the list changes during the drop (#9116)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2678 $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2679
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2680 if(!this.options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2681 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2682 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2683 if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2684 dropped = this._drop.call(this, event) || dropped;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2685 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2686
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2687 if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2688 this.isout = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2689 this.isover = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2690 this._deactivate.call(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2691 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2692
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2693 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2694 return dropped;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2696 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2697 dragStart: function( draggable, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2698 //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2699 draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2700 if( !draggable.options.refreshPositions ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2701 $.ui.ddmanager.prepareOffsets( draggable, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2702 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2703 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2704 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2705 drag: function(draggable, event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2706
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2707 //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2708 if(draggable.options.refreshPositions) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2709 $.ui.ddmanager.prepareOffsets(draggable, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2710 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2711
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2712 //Run through all droppables and check their positions based on specific tolerance options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2713 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2714
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2715 if(this.options.disabled || this.greedyChild || !this.visible) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2716 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2717 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2718
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2719 var parentInstance, scope, parent,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2720 intersects = $.ui.intersect(draggable, this, this.options.tolerance),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2721 c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2722 if(!c) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2723 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2724 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2725
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2726 if (this.options.greedy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2727 // find droppable parents with same scope
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2728 scope = this.options.scope;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2729 parent = this.element.parents(":data(ui-droppable)").filter(function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2730 return $.data(this, "ui-droppable").options.scope === scope;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2731 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2733 if (parent.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2734 parentInstance = $.data(parent[0], "ui-droppable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2735 parentInstance.greedyChild = (c === "isover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2736 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2737 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2738
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2739 // we just moved into a greedy child
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2740 if (parentInstance && c === "isover") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2741 parentInstance.isover = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2742 parentInstance.isout = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2743 parentInstance._out.call(parentInstance, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2745
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2746 this[c] = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2747 this[c === "isout" ? "isover" : "isout"] = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2748 this[c === "isover" ? "_over" : "_out"].call(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2749
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2750 // we just moved out of a greedy child
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2751 if (parentInstance && c === "isout") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2752 parentInstance.isout = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2753 parentInstance.isover = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2754 parentInstance._over.call(parentInstance, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2755 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2756 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2757
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2758 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2759 dragStop: function( draggable, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2760 draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2761 //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2762 if( !draggable.options.refreshPositions ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2763 $.ui.ddmanager.prepareOffsets( draggable, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2764 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2765 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2766 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2767
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2768 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2769 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2770
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2771 function num(v) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2772 return parseInt(v, 10) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2773 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2774
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2775 function isNumber(value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2776 return !isNaN(parseInt(value, 10));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2777 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2778
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2779 $.widget("ui.resizable", $.ui.mouse, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2780 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2781 widgetEventPrefix: "resize",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2782 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2783 alsoResize: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2784 animate: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2785 animateDuration: "slow",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2786 animateEasing: "swing",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2787 aspectRatio: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2788 autoHide: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2789 containment: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2790 ghost: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2791 grid: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2792 handles: "e,s,se",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2793 helper: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2794 maxHeight: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2795 maxWidth: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2796 minHeight: 10,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2797 minWidth: 10,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2798 // See #7960
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2799 zIndex: 90,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2800
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2801 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2802 resize: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2803 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2804 stop: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2805 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2806 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2807
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2808 var n, i, handle, axis, hname,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2809 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2810 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2811 this.element.addClass("ui-resizable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2812
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2813 $.extend(this, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2814 _aspectRatio: !!(o.aspectRatio),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2815 aspectRatio: o.aspectRatio,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2816 originalElement: this.element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2817 _proportionallyResizeElements: [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2818 _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2819 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2820
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2821 //Wrap the element if it cannot hold child nodes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2822 if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2823
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2824 //Create a wrapper element and set the wrapper to the new current internal element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2825 this.element.wrap(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2826 $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2827 position: this.element.css("position"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2828 width: this.element.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2829 height: this.element.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2830 top: this.element.css("top"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2831 left: this.element.css("left")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2832 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2833 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2834
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2835 //Overwrite the original this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2836 this.element = this.element.parent().data(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2837 "ui-resizable", this.element.data("ui-resizable")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2838 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2839
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2840 this.elementIsWrapper = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2841
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2842 //Move margins to the wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2843 this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2844 this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2845
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2846 //Prevent Safari textarea resize
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2847 this.originalResizeStyle = this.originalElement.css("resize");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2848 this.originalElement.css("resize", "none");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2849
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2850 //Push the actual element to our proportionallyResize internal array
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2851 this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2852
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2853 // avoid IE jump (hard set the margin)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2854 this.originalElement.css({ margin: this.originalElement.css("margin") });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2855
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2856 // fix handlers offset
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2857 this._proportionallyResize();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2858
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2859 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2860
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2861 this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2862 if(this.handles.constructor === String) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2863
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2864 if ( this.handles === "all") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2865 this.handles = "n,e,s,w,se,sw,ne,nw";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2866 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2867
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2868 n = this.handles.split(",");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2869 this.handles = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2870
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2871 for(i = 0; i < n.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2872
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2873 handle = $.trim(n[i]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2874 hname = "ui-resizable-"+handle;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2875 axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2877 // Apply zIndex to all handles - see #7960
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2878 axis.css({ zIndex: o.zIndex });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2879
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2880 //TODO : What's going on here?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2881 if ("se" === handle) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2882 axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2883 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2884
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2885 //Insert into internal handles object and append to element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2886 this.handles[handle] = ".ui-resizable-"+handle;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2887 this.element.append(axis);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2888 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2889
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2890 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2891
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2892 this._renderAxis = function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2893
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2894 var i, axis, padPos, padWrapper;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2895
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2896 target = target || this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2897
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2898 for(i in this.handles) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2899
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2900 if(this.handles[i].constructor === String) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2901 this.handles[i] = $(this.handles[i], this.element).show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2902 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2903
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2904 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2905 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2906
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2907 axis = $(this.handles[i], this.element);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2908
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2909 //Checking the correct pad and border
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2910 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2911
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2912 //The padding type i have to apply...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2913 padPos = [ "padding",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2914 /ne|nw|n/.test(i) ? "Top" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2915 /se|sw|s/.test(i) ? "Bottom" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2916 /^e$/.test(i) ? "Right" : "Left" ].join("");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2917
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2918 target.css(padPos, padWrapper);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2919
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2920 this._proportionallyResize();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2921
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2922 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2923
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2924 //TODO: What's that good for? There's not anything to be executed left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2925 if(!$(this.handles[i]).length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2926 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2927 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2928 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2929 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2930
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2931 //TODO: make renderAxis a prototype function
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2932 this._renderAxis(this.element);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2933
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2934 this._handles = $(".ui-resizable-handle", this.element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2935 .disableSelection();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2936
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2937 //Matching axis name
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2938 this._handles.mouseover(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2939 if (!that.resizing) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2940 if (this.className) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2941 axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2942 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2943 //Axis, default = se
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2944 that.axis = axis && axis[1] ? axis[1] : "se";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2945 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2946 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2947
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2948 //If we want to auto hide the elements
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2949 if (o.autoHide) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2950 this._handles.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2951 $(this.element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2952 .addClass("ui-resizable-autohide")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2953 .mouseenter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2954 if (o.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2955 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2956 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2957 $(this).removeClass("ui-resizable-autohide");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2958 that._handles.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2959 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2960 .mouseleave(function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2961 if (o.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2962 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2963 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2964 if (!that.resizing) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2965 $(this).addClass("ui-resizable-autohide");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2966 that._handles.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2967 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2968 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2969 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2970
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2971 //Initialize the mouse interaction
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2972 this._mouseInit();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2973
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2974 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2975
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2976 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2977
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2978 this._mouseDestroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2979
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2980 var wrapper,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2981 _destroy = function(exp) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2982 $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2983 .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2984 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2985
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2986 //TODO: Unwrap at same DOM position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2987 if (this.elementIsWrapper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2988 _destroy(this.element);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2989 wrapper = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2990 this.originalElement.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2991 position: wrapper.css("position"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2992 width: wrapper.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2993 height: wrapper.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2994 top: wrapper.css("top"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2995 left: wrapper.css("left")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2996 }).insertAfter( wrapper );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2997 wrapper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2998 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2999
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3000 this.originalElement.css("resize", this.originalResizeStyle);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3001 _destroy(this.originalElement);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3003 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3004 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3005
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3006 _mouseCapture: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3007 var i, handle,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3008 capture = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3009
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3010 for (i in this.handles) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3011 handle = $(this.handles[i])[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3012 if (handle === event.target || $.contains(handle, event.target)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3013 capture = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3014 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3015 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3016
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3017 return !this.options.disabled && capture;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3018 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3019
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3020 _mouseStart: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3021
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3022 var curleft, curtop, cursor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3023 o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3024 iniPos = this.element.position(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3025 el = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3026
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3027 this.resizing = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3028
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3029 // bugfix for http://dev.jquery.com/ticket/1749
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3030 if ( (/absolute/).test( el.css("position") ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3031 el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3032 } else if (el.is(".ui-draggable")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3033 el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3034 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3035
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3036 this._renderProxy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3037
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3038 curleft = num(this.helper.css("left"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3039 curtop = num(this.helper.css("top"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3040
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3041 if (o.containment) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3042 curleft += $(o.containment).scrollLeft() || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3043 curtop += $(o.containment).scrollTop() || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3044 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3045
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3046 //Store needed variables
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3047 this.offset = this.helper.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3048 this.position = { left: curleft, top: curtop };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3049 this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3050 this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3051 this.originalPosition = { left: curleft, top: curtop };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3052 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3053 this.originalMousePosition = { left: event.pageX, top: event.pageY };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3054
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3055 //Aspect Ratio
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3056 this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3057
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3058 cursor = $(".ui-resizable-" + this.axis).css("cursor");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3059 $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3061 el.addClass("ui-resizable-resizing");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3062 this._propagate("start", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3063 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3064 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3065
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3066 _mouseDrag: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3067
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3068 //Increase performance, avoid regex
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3069 var data,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3070 el = this.helper, props = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3071 smp = this.originalMousePosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3072 a = this.axis,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3073 prevTop = this.position.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3074 prevLeft = this.position.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3075 prevWidth = this.size.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3076 prevHeight = this.size.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3077 dx = (event.pageX-smp.left)||0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3078 dy = (event.pageY-smp.top)||0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3079 trigger = this._change[a];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3080
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3081 if (!trigger) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3082 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3083 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3084
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3085 // Calculate the attrs that will be change
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3086 data = trigger.apply(this, [event, dx, dy]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3087
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3088 // Put this in the mouseDrag handler since the user can start pressing shift while resizing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3089 this._updateVirtualBoundaries(event.shiftKey);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3090 if (this._aspectRatio || event.shiftKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3091 data = this._updateRatio(data, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3092 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3093
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3094 data = this._respectSize(data, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3095
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3096 this._updateCache(data);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3097
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3098 // plugins callbacks need to be called first
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3099 this._propagate("resize", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3100
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3101 if (this.position.top !== prevTop) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3102 props.top = this.position.top + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3103 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3104 if (this.position.left !== prevLeft) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3105 props.left = this.position.left + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3106 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3107 if (this.size.width !== prevWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3108 props.width = this.size.width + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3109 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3110 if (this.size.height !== prevHeight) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3111 props.height = this.size.height + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3112 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3113 el.css(props);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3114
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3115 if (!this._helper && this._proportionallyResizeElements.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3116 this._proportionallyResize();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3117 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3118
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3119 // Call the user callback if the element was resized
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3120 if ( ! $.isEmptyObject(props) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3121 this._trigger("resize", event, this.ui());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3122 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3123
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3124 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3125 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3126
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3127 _mouseStop: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3128
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3129 this.resizing = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3130 var pr, ista, soffseth, soffsetw, s, left, top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3131 o = this.options, that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3132
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3133 if(this._helper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3134
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3135 pr = this._proportionallyResizeElements;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3136 ista = pr.length && (/textarea/i).test(pr[0].nodeName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3137 soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3138 soffsetw = ista ? 0 : that.sizeDiff.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3139
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3140 s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3141 left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3142 top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3143
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3144 if (!o.animate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3145 this.element.css($.extend(s, { top: top, left: left }));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3146 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3147
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3148 that.helper.height(that.size.height);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3149 that.helper.width(that.size.width);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3150
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3151 if (this._helper && !o.animate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3152 this._proportionallyResize();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3153 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3154 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3155
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3156 $("body").css("cursor", "auto");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3157
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3158 this.element.removeClass("ui-resizable-resizing");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3159
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3160 this._propagate("stop", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3161
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3162 if (this._helper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3163 this.helper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3164 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3166 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3167
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3168 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3169
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3170 _updateVirtualBoundaries: function(forceAspectRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3171 var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3172 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3173
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3174 b = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3175 minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3176 maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3177 minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3178 maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3179 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3180
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3181 if(this._aspectRatio || forceAspectRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3182 // We want to create an enclosing box whose aspect ration is the requested one
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3183 // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3184 pMinWidth = b.minHeight * this.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3185 pMinHeight = b.minWidth / this.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3186 pMaxWidth = b.maxHeight * this.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3187 pMaxHeight = b.maxWidth / this.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3188
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3189 if(pMinWidth > b.minWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3190 b.minWidth = pMinWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3191 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3192 if(pMinHeight > b.minHeight) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3193 b.minHeight = pMinHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3194 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3195 if(pMaxWidth < b.maxWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3196 b.maxWidth = pMaxWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3197 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3198 if(pMaxHeight < b.maxHeight) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3199 b.maxHeight = pMaxHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3200 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3201 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3202 this._vBoundaries = b;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3203 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3204
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3205 _updateCache: function(data) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3206 this.offset = this.helper.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3207 if (isNumber(data.left)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3208 this.position.left = data.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3209 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3210 if (isNumber(data.top)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3211 this.position.top = data.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3212 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3213 if (isNumber(data.height)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3214 this.size.height = data.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3215 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3216 if (isNumber(data.width)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3217 this.size.width = data.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3218 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3219 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3220
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3221 _updateRatio: function( data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3222
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3223 var cpos = this.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3224 csize = this.size,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3225 a = this.axis;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3226
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3227 if (isNumber(data.height)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3228 data.width = (data.height * this.aspectRatio);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3229 } else if (isNumber(data.width)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3230 data.height = (data.width / this.aspectRatio);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3231 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3232
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3233 if (a === "sw") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3234 data.left = cpos.left + (csize.width - data.width);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3235 data.top = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3236 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3237 if (a === "nw") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3238 data.top = cpos.top + (csize.height - data.height);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3239 data.left = cpos.left + (csize.width - data.width);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3240 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3241
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3242 return data;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3243 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3245 _respectSize: function( data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3246
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3247 var o = this._vBoundaries,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3248 a = this.axis,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3249 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3250 isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3251 dw = this.originalPosition.left + this.originalSize.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3252 dh = this.position.top + this.size.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3253 cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3254 if (isminw) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3255 data.width = o.minWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3256 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3257 if (isminh) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3258 data.height = o.minHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3259 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3260 if (ismaxw) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3261 data.width = o.maxWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3262 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3263 if (ismaxh) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3264 data.height = o.maxHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3265 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3266
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3267 if (isminw && cw) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3268 data.left = dw - o.minWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3269 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3270 if (ismaxw && cw) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3271 data.left = dw - o.maxWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3272 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3273 if (isminh && ch) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3274 data.top = dh - o.minHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3275 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3276 if (ismaxh && ch) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3277 data.top = dh - o.maxHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3278 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3279
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3280 // fixing jump error on top/left - bug #2330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3281 if (!data.width && !data.height && !data.left && data.top) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3282 data.top = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3283 } else if (!data.width && !data.height && !data.top && data.left) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3284 data.left = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3285 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3286
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3287 return data;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3288 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3289
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3290 _proportionallyResize: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3291
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3292 if (!this._proportionallyResizeElements.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3293 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3294 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3295
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3296 var i, j, borders, paddings, prel,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3297 element = this.helper || this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3298
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3299 for ( i=0; i < this._proportionallyResizeElements.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3300
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3301 prel = this._proportionallyResizeElements[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3302
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3303 if (!this.borderDif) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3304 this.borderDif = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3305 borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3306 paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3307
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3308 for ( j = 0; j < borders.length; j++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3309 this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3310 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3311 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3312
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3313 prel.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3314 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3315 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3316 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3317
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3318 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3319
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3320 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3321
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3322 _renderProxy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3323
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3324 var el = this.element, o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3325 this.elementOffset = el.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3326
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3327 if(this._helper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3328
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3329 this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3331 this.helper.addClass(this._helper).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3332 width: this.element.outerWidth() - 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3333 height: this.element.outerHeight() - 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3334 position: "absolute",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3335 left: this.elementOffset.left +"px",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3336 top: this.elementOffset.top +"px",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3337 zIndex: ++o.zIndex //TODO: Don't modify option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3338 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3339
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3340 this.helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3341 .appendTo("body")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3342 .disableSelection();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3343
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3344 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3345 this.helper = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3346 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3347
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3348 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3349
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3350 _change: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3351 e: function(event, dx) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3352 return { width: this.originalSize.width + dx };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3353 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3354 w: function(event, dx) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3355 var cs = this.originalSize, sp = this.originalPosition;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3356 return { left: sp.left + dx, width: cs.width - dx };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3357 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3358 n: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3359 var cs = this.originalSize, sp = this.originalPosition;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3360 return { top: sp.top + dy, height: cs.height - dy };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3361 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3362 s: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3363 return { height: this.originalSize.height + dy };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3364 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3365 se: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3366 return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3367 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3368 sw: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3369 return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3370 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3371 ne: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3372 return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3373 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3374 nw: function(event, dx, dy) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3375 return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3376 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3377 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3378
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3379 _propagate: function(n, event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3380 $.ui.plugin.call(this, n, [event, this.ui()]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3381 (n !== "resize" && this._trigger(n, event, this.ui()));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3382 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3383
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3384 plugins: {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3386 ui: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3387 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3388 originalElement: this.originalElement,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3389 element: this.element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3390 helper: this.helper,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3391 position: this.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3392 size: this.size,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3393 originalSize: this.originalSize,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3394 originalPosition: this.originalPosition
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3395 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3396 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3397
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3398 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3399
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3400 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3401 * Resizable Extensions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3402 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3403
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3404 $.ui.plugin.add("resizable", "animate", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3405
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3406 stop: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3407 var that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3408 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3409 pr = that._proportionallyResizeElements,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3410 ista = pr.length && (/textarea/i).test(pr[0].nodeName),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3411 soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3412 soffsetw = ista ? 0 : that.sizeDiff.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3413 style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3414 left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3415 top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3416
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3417 that.element.animate(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3418 $.extend(style, top && left ? { top: top, left: left } : {}), {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3419 duration: o.animateDuration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3420 easing: o.animateEasing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3421 step: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3422
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3423 var data = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3424 width: parseInt(that.element.css("width"), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3425 height: parseInt(that.element.css("height"), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3426 top: parseInt(that.element.css("top"), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3427 left: parseInt(that.element.css("left"), 10)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3428 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3429
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3430 if (pr && pr.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3431 $(pr[0]).css({ width: data.width, height: data.height });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3432 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3433
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3434 // propagating resize, and updating values for each animation step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3435 that._updateCache(data);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3436 that._propagate("resize", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3437
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3438 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3439 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3440 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3441 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3442
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3443 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3444
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3445 $.ui.plugin.add("resizable", "containment", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3446
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3447 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3448 var element, p, co, ch, cw, width, height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3449 that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3450 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3451 el = that.element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3452 oc = o.containment,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3453 ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3454
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3455 if (!ce) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3456 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3457 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3458
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3459 that.containerElement = $(ce);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3460
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3461 if (/document/.test(oc) || oc === document) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3462 that.containerOffset = { left: 0, top: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3463 that.containerPosition = { left: 0, top: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3464
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3465 that.parentData = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3466 element: $(document), left: 0, top: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3467 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3468 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3469 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3470
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3471 // i'm a node, so compute top, left, right, bottom
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3472 else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3473 element = $(ce);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3474 p = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3475 $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3476
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3477 that.containerOffset = element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3478 that.containerPosition = element.position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3479 that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3480
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3481 co = that.containerOffset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3482 ch = that.containerSize.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3483 cw = that.containerSize.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3484 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3485 height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3486
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3487 that.parentData = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3488 element: ce, left: co.left, top: co.top, width: width, height: height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3489 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3490 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3491 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3492
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3493 resize: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3494 var woset, hoset, isParent, isOffsetRelative,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3495 that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3496 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3497 co = that.containerOffset, cp = that.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3498 pRatio = that._aspectRatio || event.shiftKey,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3499 cop = { top:0, left:0 }, ce = that.containerElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3500
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3501 if (ce[0] !== document && (/static/).test(ce.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3502 cop = co;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3503 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3504
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3505 if (cp.left < (that._helper ? co.left : 0)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3506 that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3507 if (pRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3508 that.size.height = that.size.width / that.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3509 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3510 that.position.left = o.helper ? co.left : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3511 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3512
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3513 if (cp.top < (that._helper ? co.top : 0)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3514 that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3515 if (pRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3516 that.size.width = that.size.height * that.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3517 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3518 that.position.top = that._helper ? co.top : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3519 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3520
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3521 that.offset.left = that.parentData.left+that.position.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3522 that.offset.top = that.parentData.top+that.position.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3523
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3524 woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3525 hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3526
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3527 isParent = that.containerElement.get(0) === that.element.parent().get(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3528 isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3529
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3530 if(isParent && isOffsetRelative) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3531 woset -= that.parentData.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3532 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3533
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3534 if (woset + that.size.width >= that.parentData.width) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3535 that.size.width = that.parentData.width - woset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3536 if (pRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3537 that.size.height = that.size.width / that.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3538 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3539 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3540
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3541 if (hoset + that.size.height >= that.parentData.height) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3542 that.size.height = that.parentData.height - hoset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3543 if (pRatio) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3544 that.size.width = that.size.height * that.aspectRatio;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3545 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3546 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3547 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3548
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3549 stop: function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3550 var that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3551 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3552 co = that.containerOffset,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3553 cop = that.containerPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3554 ce = that.containerElement,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3555 helper = $(that.helper),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3556 ho = helper.offset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3557 w = helper.outerWidth() - that.sizeDiff.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3558 h = helper.outerHeight() - that.sizeDiff.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3560 if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3561 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3562 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3563
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3564 if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3565 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3566 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3567
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3568 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3569 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3570
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3571 $.ui.plugin.add("resizable", "alsoResize", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3572
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3573 start: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3574 var that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3575 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3576 _store = function (exp) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3577 $(exp).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3578 var el = $(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3579 el.data("ui-resizable-alsoresize", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3580 width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3581 left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3582 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3583 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3584 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3585
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3586 if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3587 if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3588 else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3589 }else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3590 _store(o.alsoResize);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3591 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3592 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3593
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3594 resize: function (event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3595 var that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3596 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3597 os = that.originalSize,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3598 op = that.originalPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3599 delta = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3600 height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3601 top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3602 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3603
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3604 _alsoResize = function (exp, c) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3605 $(exp).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3606 var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3607 css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3608
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3609 $.each(css, function (i, prop) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3610 var sum = (start[prop]||0) + (delta[prop]||0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3611 if (sum && sum >= 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3612 style[prop] = sum || null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3613 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3614 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3615
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3616 el.css(style);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3617 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3618 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3619
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3620 if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3621 $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3622 }else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3623 _alsoResize(o.alsoResize);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3624 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3625 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3626
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3627 stop: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3628 $(this).removeData("resizable-alsoresize");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3629 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3630 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3631
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3632 $.ui.plugin.add("resizable", "ghost", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3634 start: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3635
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3636 var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3638 that.ghost = that.originalElement.clone();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3639 that.ghost
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3640 .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3641 .addClass("ui-resizable-ghost")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3642 .addClass(typeof o.ghost === "string" ? o.ghost : "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3643
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3644 that.ghost.appendTo(that.helper);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3645
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3646 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3647
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3648 resize: function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3649 var that = $(this).data("ui-resizable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3650 if (that.ghost) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3651 that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3652 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3653 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3654
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3655 stop: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3656 var that = $(this).data("ui-resizable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3657 if (that.ghost && that.helper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3658 that.helper.get(0).removeChild(that.ghost.get(0));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3659 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3660 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3661
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3662 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3663
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3664 $.ui.plugin.add("resizable", "grid", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3665
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3666 resize: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3667 var that = $(this).data("ui-resizable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3668 o = that.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3669 cs = that.size,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3670 os = that.originalSize,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3671 op = that.originalPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3672 a = that.axis,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3673 grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3674 gridX = (grid[0]||1),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3675 gridY = (grid[1]||1),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3676 ox = Math.round((cs.width - os.width) / gridX) * gridX,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3677 oy = Math.round((cs.height - os.height) / gridY) * gridY,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3678 newWidth = os.width + ox,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3679 newHeight = os.height + oy,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3680 isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3681 isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3682 isMinWidth = o.minWidth && (o.minWidth > newWidth),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3683 isMinHeight = o.minHeight && (o.minHeight > newHeight);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3684
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3685 o.grid = grid;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3686
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3687 if (isMinWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3688 newWidth = newWidth + gridX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3689 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3690 if (isMinHeight) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3691 newHeight = newHeight + gridY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3692 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3693 if (isMaxWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3694 newWidth = newWidth - gridX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3695 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3696 if (isMaxHeight) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3697 newHeight = newHeight - gridY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3698 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3699
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3700 if (/^(se|s|e)$/.test(a)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3701 that.size.width = newWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3702 that.size.height = newHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3703 } else if (/^(ne)$/.test(a)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3704 that.size.width = newWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3705 that.size.height = newHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3706 that.position.top = op.top - oy;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3707 } else if (/^(sw)$/.test(a)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3708 that.size.width = newWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3709 that.size.height = newHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3710 that.position.left = op.left - ox;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3711 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3712 that.size.width = newWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3713 that.size.height = newHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3714 that.position.top = op.top - oy;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3715 that.position.left = op.left - ox;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3716 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3717 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3718
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3719 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3720
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3721 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3722 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3723
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3724 $.widget("ui.selectable", $.ui.mouse, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3725 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3726 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3727 appendTo: "body",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3728 autoRefresh: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3729 distance: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3730 filter: "*",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3731 tolerance: "touch",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3733 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3734 selected: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3735 selecting: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3736 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3737 stop: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3738 unselected: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3739 unselecting: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3740 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3741 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3742 var selectees,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3743 that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3744
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3745 this.element.addClass("ui-selectable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3746
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3747 this.dragged = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3748
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3749 // cache selectee children based on filter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3750 this.refresh = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3751 selectees = $(that.options.filter, that.element[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3752 selectees.addClass("ui-selectee");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3753 selectees.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3754 var $this = $(this),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3755 pos = $this.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3756 $.data(this, "selectable-item", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3757 element: this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3758 $element: $this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3759 left: pos.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3760 top: pos.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3761 right: pos.left + $this.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3762 bottom: pos.top + $this.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3763 startselected: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3764 selected: $this.hasClass("ui-selected"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3765 selecting: $this.hasClass("ui-selecting"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3766 unselecting: $this.hasClass("ui-unselecting")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3767 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3768 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3769 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3770 this.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3771
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3772 this.selectees = selectees.addClass("ui-selectee");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3773
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3774 this._mouseInit();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3775
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3776 this.helper = $("<div class='ui-selectable-helper'></div>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3777 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3778
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3779 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3780 this.selectees
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3781 .removeClass("ui-selectee")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3782 .removeData("selectable-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3783 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3784 .removeClass("ui-selectable ui-selectable-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3785 this._mouseDestroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3786 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3787
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3788 _mouseStart: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3789 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3790 options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3791
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3792 this.opos = [event.pageX, event.pageY];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3794 if (this.options.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3795 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3796 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3797
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3798 this.selectees = $(options.filter, this.element[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3799
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3800 this._trigger("start", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3801
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3802 $(options.appendTo).append(this.helper);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3803 // position helper (lasso)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3804 this.helper.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3805 "left": event.pageX,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3806 "top": event.pageY,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3807 "width": 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3808 "height": 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3809 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3810
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3811 if (options.autoRefresh) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3812 this.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3813 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3814
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3815 this.selectees.filter(".ui-selected").each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3816 var selectee = $.data(this, "selectable-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3817 selectee.startselected = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3818 if (!event.metaKey && !event.ctrlKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3819 selectee.$element.removeClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3820 selectee.selected = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3821 selectee.$element.addClass("ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3822 selectee.unselecting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3823 // selectable UNSELECTING callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3824 that._trigger("unselecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3825 unselecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3826 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3827 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3828 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3829
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3830 $(event.target).parents().addBack().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3831 var doSelect,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3832 selectee = $.data(this, "selectable-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3833 if (selectee) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3834 doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3835 selectee.$element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3836 .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3837 .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3838 selectee.unselecting = !doSelect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3839 selectee.selecting = doSelect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3840 selectee.selected = doSelect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3841 // selectable (UN)SELECTING callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3842 if (doSelect) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3843 that._trigger("selecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3844 selecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3845 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3846 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3847 that._trigger("unselecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3848 unselecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3849 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3850 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3851 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3852 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3853 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3854
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3855 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3856
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3857 _mouseDrag: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3858
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3859 this.dragged = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3860
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3861 if (this.options.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3862 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3863 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3864
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3865 var tmp,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3866 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3867 options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3868 x1 = this.opos[0],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3869 y1 = this.opos[1],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3870 x2 = event.pageX,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3871 y2 = event.pageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3872
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3873 if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3874 if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3875 this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3877 this.selectees.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3878 var selectee = $.data(this, "selectable-item"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3879 hit = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3880
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3881 //prevent helper from being selected if appendTo: selectable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3882 if (!selectee || selectee.element === that.element[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3883 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3884 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3885
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3886 if (options.tolerance === "touch") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3887 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3888 } else if (options.tolerance === "fit") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3889 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3890 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3891
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3892 if (hit) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3893 // SELECT
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3894 if (selectee.selected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3895 selectee.$element.removeClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3896 selectee.selected = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3897 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3898 if (selectee.unselecting) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3899 selectee.$element.removeClass("ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3900 selectee.unselecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3901 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3902 if (!selectee.selecting) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3903 selectee.$element.addClass("ui-selecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3904 selectee.selecting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3905 // selectable SELECTING callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3906 that._trigger("selecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3907 selecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3908 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3909 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3910 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3911 // UNSELECT
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3912 if (selectee.selecting) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3913 if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3914 selectee.$element.removeClass("ui-selecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3915 selectee.selecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3916 selectee.$element.addClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3917 selectee.selected = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3918 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3919 selectee.$element.removeClass("ui-selecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3920 selectee.selecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3921 if (selectee.startselected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3922 selectee.$element.addClass("ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3923 selectee.unselecting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3924 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3925 // selectable UNSELECTING callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3926 that._trigger("unselecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3927 unselecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3928 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3929 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3930 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3931 if (selectee.selected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3932 if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3933 selectee.$element.removeClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3934 selectee.selected = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3935
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3936 selectee.$element.addClass("ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3937 selectee.unselecting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3938 // selectable UNSELECTING callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3939 that._trigger("unselecting", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3940 unselecting: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3941 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3942 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3943 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3944 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3945 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3946
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3947 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3948 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3949
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3950 _mouseStop: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3951 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3953 this.dragged = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3954
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3955 $(".ui-unselecting", this.element[0]).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3956 var selectee = $.data(this, "selectable-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3957 selectee.$element.removeClass("ui-unselecting");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3958 selectee.unselecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3959 selectee.startselected = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3960 that._trigger("unselected", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3961 unselected: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3962 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3963 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3964 $(".ui-selecting", this.element[0]).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3965 var selectee = $.data(this, "selectable-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3966 selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3967 selectee.selecting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3968 selectee.selected = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3969 selectee.startselected = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3970 that._trigger("selected", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3971 selected: selectee.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3972 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3973 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3974 this._trigger("stop", event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3975
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3976 this.helper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3977
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3978 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3979 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3980
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3981 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3982
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3983 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3984 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3985
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3986 /*jshint loopfunc: true */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3987
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3988 function isOverAxis( x, reference, size ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3989 return ( x > reference ) && ( x < ( reference + size ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3990 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3991
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3992 function isFloating(item) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3993 return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3994 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3995
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3996 $.widget("ui.sortable", $.ui.mouse, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3997 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3998 widgetEventPrefix: "sort",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3999 ready: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4000 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4001 appendTo: "parent",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4002 axis: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4003 connectWith: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4004 containment: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4005 cursor: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4006 cursorAt: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4007 dropOnEmpty: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4008 forcePlaceholderSize: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4009 forceHelperSize: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4010 grid: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4011 handle: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4012 helper: "original",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4013 items: "> *",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4014 opacity: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4015 placeholder: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4016 revert: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4017 scroll: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4018 scrollSensitivity: 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4019 scrollSpeed: 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4020 scope: "default",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4021 tolerance: "intersect",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4022 zIndex: 1000,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4023
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4024 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4025 activate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4026 beforeStop: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4027 change: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4028 deactivate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4029 out: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4030 over: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4031 receive: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4032 remove: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4033 sort: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4034 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4035 stop: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4036 update: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4037 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4038 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4039
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4040 var o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4041 this.containerCache = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4042 this.element.addClass("ui-sortable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4043
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4044 //Get the items
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4045 this.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4046
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4047 //Let's determine if the items are being displayed horizontally
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4048 this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4049
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4050 //Let's determine the parent's offset
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4051 this.offset = this.element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4052
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4053 //Initialize mouse events for interaction
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4054 this._mouseInit();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4055
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4056 //We're ready to go
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4057 this.ready = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4058
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4059 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4061 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4062 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4063 .removeClass("ui-sortable ui-sortable-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4064 this._mouseDestroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4065
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4066 for ( var i = this.items.length - 1; i >= 0; i-- ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4067 this.items[i].item.removeData(this.widgetName + "-item");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4068 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4069
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4070 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4071 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4072
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4073 _setOption: function(key, value){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4074 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4075 this.options[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4076
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4077 this.widget().toggleClass( "ui-sortable-disabled", !!value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4078 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4079 // Don't call widget base _setOption for disable as it adds ui-state-disabled class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4080 $.Widget.prototype._setOption.apply(this, arguments);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4081 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4082 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4083
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4084 _mouseCapture: function(event, overrideHandle) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4085 var currentItem = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4086 validHandle = false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4087 that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4088
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4089 if (this.reverting) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4090 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4091 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4092
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4093 if(this.options.disabled || this.options.type === "static") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4094 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4095 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4096
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4097 //We have to refresh the items data once first
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4098 this._refreshItems(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4099
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4100 //Find out if the clicked node (or one of its parents) is a actual item in this.items
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4101 $(event.target).parents().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4102 if($.data(this, that.widgetName + "-item") === that) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4103 currentItem = $(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4104 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4105 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4106 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4107 if($.data(event.target, that.widgetName + "-item") === that) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4108 currentItem = $(event.target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4109 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4110
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4111 if(!currentItem) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4112 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4113 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4114 if(this.options.handle && !overrideHandle) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4115 $(this.options.handle, currentItem).find("*").addBack().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4116 if(this === event.target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4117 validHandle = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4118 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4119 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4120 if(!validHandle) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4121 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4122 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4123 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4124
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4125 this.currentItem = currentItem;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4126 this._removeCurrentsFromItems();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4127 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4128
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4129 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4130
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4131 _mouseStart: function(event, overrideHandle, noActivation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4132
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4133 var i, body,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4134 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4135
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4136 this.currentContainer = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4137
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4138 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4139 this.refreshPositions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4140
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4141 //Create and append the visible helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4142 this.helper = this._createHelper(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4143
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4144 //Cache the helper size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4145 this._cacheHelperProportions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4146
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4147 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4148 * - Position generation -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4149 * This block generates everything position related - it's the core of draggables.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4150 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4151
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4152 //Cache the margins of the original element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4153 this._cacheMargins();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4154
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4155 //Get the next scrolling parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4156 this.scrollParent = this.helper.scrollParent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4157
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4158 //The element's absolute position on the page minus margins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4159 this.offset = this.currentItem.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4160 this.offset = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4161 top: this.offset.top - this.margins.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4162 left: this.offset.left - this.margins.left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4163 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4164
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4165 $.extend(this.offset, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4166 click: { //Where the click happened, relative to the element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4167 left: event.pageX - this.offset.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4168 top: event.pageY - this.offset.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4169 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4170 parent: this._getParentOffset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4171 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4172 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4173
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4174 // Only after we got the offset, we can change the helper's position to absolute
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4175 // TODO: Still need to figure out a way to make relative sorting possible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4176 this.helper.css("position", "absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4177 this.cssPosition = this.helper.css("position");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4178
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4179 //Generate the original position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4180 this.originalPosition = this._generatePosition(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4181 this.originalPageX = event.pageX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4182 this.originalPageY = event.pageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4183
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4184 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4185 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4186
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4187 //Cache the former DOM position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4188 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4189
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4190 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4191 if(this.helper[0] !== this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4192 this.currentItem.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4193 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4194
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4195 //Create the placeholder
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4196 this._createPlaceholder();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4197
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4198 //Set a containment if given in the options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4199 if(o.containment) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4200 this._setContainment();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4201 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4202
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4203 if( o.cursor && o.cursor !== "auto" ) { // cursor option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4204 body = this.document.find( "body" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4205
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4206 // support: IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4207 this.storedCursor = body.css( "cursor" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4208 body.css( "cursor", o.cursor );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4209
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4210 this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4211 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4212
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4213 if(o.opacity) { // opacity option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4214 if (this.helper.css("opacity")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4215 this._storedOpacity = this.helper.css("opacity");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4216 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4217 this.helper.css("opacity", o.opacity);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4218 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4219
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4220 if(o.zIndex) { // zIndex option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4221 if (this.helper.css("zIndex")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4222 this._storedZIndex = this.helper.css("zIndex");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4223 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4224 this.helper.css("zIndex", o.zIndex);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4225 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4226
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4227 //Prepare scrolling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4228 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4229 this.overflowOffset = this.scrollParent.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4230 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4231
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4232 //Call callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4233 this._trigger("start", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4234
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4235 //Recache the helper size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4236 if(!this._preserveHelperProportions) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4237 this._cacheHelperProportions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4238 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4239
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4240
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4241 //Post "activate" events to possible containers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4242 if( !noActivation ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4243 for ( i = this.containers.length - 1; i >= 0; i-- ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4244 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4245 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4246 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4247
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4248 //Prepare possible droppables
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4249 if($.ui.ddmanager) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4250 $.ui.ddmanager.current = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4251 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4252
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4253 if ($.ui.ddmanager && !o.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4254 $.ui.ddmanager.prepareOffsets(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4255 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4256
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4257 this.dragging = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4258
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4259 this.helper.addClass("ui-sortable-helper");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4260 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4261 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4262
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4263 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4264
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4265 _mouseDrag: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4266 var i, item, itemElement, intersection,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4267 o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4268 scrolled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4269
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4270 //Compute the helpers position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4271 this.position = this._generatePosition(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4272 this.positionAbs = this._convertPositionTo("absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4273
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4274 if (!this.lastPositionAbs) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4275 this.lastPositionAbs = this.positionAbs;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4276 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4277
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4278 //Do scrolling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4279 if(this.options.scroll) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4280 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4281
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4282 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4283 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4284 } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4285 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4286 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4287
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4288 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4289 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4290 } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4291 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4292 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4293
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4294 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4295
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4296 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4297 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4298 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4299 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4300 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4301
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4302 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4303 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4304 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4305 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4306 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4307
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4308 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4309
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4310 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4311 $.ui.ddmanager.prepareOffsets(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4312 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4313 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4314
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4315 //Regenerate the absolute position used for position checks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4316 this.positionAbs = this._convertPositionTo("absolute");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4317
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4318 //Set the helper position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4319 if(!this.options.axis || this.options.axis !== "y") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4320 this.helper[0].style.left = this.position.left+"px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4321 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4322 if(!this.options.axis || this.options.axis !== "x") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4323 this.helper[0].style.top = this.position.top+"px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4324 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4325
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4326 //Rearrange
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4327 for (i = this.items.length - 1; i >= 0; i--) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4328
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4329 //Cache variables and intersection, continue if no intersection
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4330 item = this.items[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4331 itemElement = item.item[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4332 intersection = this._intersectsWithPointer(item);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4333 if (!intersection) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4334 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4335 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4336
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4337 // Only put the placeholder inside the current Container, skip all
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4338 // items form other containers. This works because when moving
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4339 // an item from one container to another the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4340 // currentContainer is switched before the placeholder is moved.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4341 //
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4342 // Without this moving items in "sub-sortables" can cause the placeholder to jitter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4343 // beetween the outer and inner container.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4344 if (item.instance !== this.currentContainer) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4345 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4346 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4347
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4348 // cannot intersect with itself
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4349 // no useless actions that have been done before
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4350 // no action if the item moved is the parent of the item checked
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4351 if (itemElement !== this.currentItem[0] &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4352 this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4353 !$.contains(this.placeholder[0], itemElement) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4354 (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4355 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4356
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4357 this.direction = intersection === 1 ? "down" : "up";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4358
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4359 if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4360 this._rearrange(event, item);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4361 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4362 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4363 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4364
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4365 this._trigger("change", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4366 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4367 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4368 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4369
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4370 //Post events to containers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4371 this._contactContainers(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4372
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4373 //Interconnect with droppables
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4374 if($.ui.ddmanager) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4375 $.ui.ddmanager.drag(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4376 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4377
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4378 //Call callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4379 this._trigger("sort", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4380
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4381 this.lastPositionAbs = this.positionAbs;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4382 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4383
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4384 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4386 _mouseStop: function(event, noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4387
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4388 if(!event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4389 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4390 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4391
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4392 //If we are using droppables, inform the manager about the drop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4393 if ($.ui.ddmanager && !this.options.dropBehaviour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4394 $.ui.ddmanager.drop(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4395 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4396
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4397 if(this.options.revert) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4398 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4399 cur = this.placeholder.offset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4400 axis = this.options.axis,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4401 animation = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4402
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4403 if ( !axis || axis === "x" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4404 animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4405 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4406 if ( !axis || axis === "y" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4407 animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4408 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4409 this.reverting = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4410 $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4411 that._clear(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4412 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4413 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4414 this._clear(event, noPropagation);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4415 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4416
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4417 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4418
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4419 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4420
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4421 cancel: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4422
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4423 if(this.dragging) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4424
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4425 this._mouseUp({ target: null });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4426
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4427 if(this.options.helper === "original") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4428 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4429 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4430 this.currentItem.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4431 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4432
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4433 //Post deactivating events to containers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4434 for (var i = this.containers.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4435 this.containers[i]._trigger("deactivate", null, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4436 if(this.containers[i].containerCache.over) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4437 this.containers[i]._trigger("out", null, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4438 this.containers[i].containerCache.over = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4439 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4440 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4441
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4442 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4444 if (this.placeholder) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4445 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4446 if(this.placeholder[0].parentNode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4447 this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4448 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4449 if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4450 this.helper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4451 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4452
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4453 $.extend(this, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4454 helper: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4455 dragging: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4456 reverting: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4457 _noFinalSort: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4458 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4459
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4460 if(this.domPosition.prev) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4461 $(this.domPosition.prev).after(this.currentItem);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4462 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4463 $(this.domPosition.parent).prepend(this.currentItem);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4464 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4465 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4466
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4467 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4468
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4469 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4470
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4471 serialize: function(o) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4472
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4473 var items = this._getItemsAsjQuery(o && o.connected),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4474 str = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4475 o = o || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4476
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4477 $(items).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4478 var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4479 if (res) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4480 str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4481 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4482 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4483
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4484 if(!str.length && o.key) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4485 str.push(o.key + "=");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4486 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4487
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4488 return str.join("&");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4489
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4490 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4491
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4492 toArray: function(o) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4493
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4494 var items = this._getItemsAsjQuery(o && o.connected),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4495 ret = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4496
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4497 o = o || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4498
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4499 items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4500 return ret;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4501
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4502 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4503
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4504 /* Be careful with the following core functions */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4505 _intersectsWith: function(item) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4506
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4507 var x1 = this.positionAbs.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4508 x2 = x1 + this.helperProportions.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4509 y1 = this.positionAbs.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4510 y2 = y1 + this.helperProportions.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4511 l = item.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4512 r = l + item.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4513 t = item.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4514 b = t + item.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4515 dyClick = this.offset.click.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4516 dxClick = this.offset.click.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4517 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4518 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4519 isOverElement = isOverElementHeight && isOverElementWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4520
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4521 if ( this.options.tolerance === "pointer" ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4522 this.options.forcePointerForContainers ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4523 (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4524 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4525 return isOverElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4526 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4527
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4528 return (l < x1 + (this.helperProportions.width / 2) && // Right Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4529 x2 - (this.helperProportions.width / 2) < r && // Left Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4530 t < y1 + (this.helperProportions.height / 2) && // Bottom Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4531 y2 - (this.helperProportions.height / 2) < b ); // Top Half
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4532
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4533 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4534 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4536 _intersectsWithPointer: function(item) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4537
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4538 var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4539 isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4540 isOverElement = isOverElementHeight && isOverElementWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4541 verticalDirection = this._getDragVerticalDirection(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4542 horizontalDirection = this._getDragHorizontalDirection();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4543
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4544 if (!isOverElement) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4545 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4546 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4547
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4548 return this.floating ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4549 ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4550 : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4551
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4552 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4553
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4554 _intersectsWithSides: function(item) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4555
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4556 var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4557 isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4558 verticalDirection = this._getDragVerticalDirection(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4559 horizontalDirection = this._getDragHorizontalDirection();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4560
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4561 if (this.floating && horizontalDirection) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4562 return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4563 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4564 return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4565 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4566
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4567 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4568
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4569 _getDragVerticalDirection: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4570 var delta = this.positionAbs.top - this.lastPositionAbs.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4571 return delta !== 0 && (delta > 0 ? "down" : "up");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4572 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4573
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4574 _getDragHorizontalDirection: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4575 var delta = this.positionAbs.left - this.lastPositionAbs.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4576 return delta !== 0 && (delta > 0 ? "right" : "left");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4577 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4578
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4579 refresh: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4580 this._refreshItems(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4581 this.refreshPositions();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4582 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4583 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4584
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4585 _connectWith: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4586 var options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4587 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4588 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4589
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4590 _getItemsAsjQuery: function(connected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4591
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4592 var i, j, cur, inst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4593 items = [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4594 queries = [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4595 connectWith = this._connectWith();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4596
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4597 if(connectWith && connected) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4598 for (i = connectWith.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4599 cur = $(connectWith[i]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4600 for ( j = cur.length - 1; j >= 0; j--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4601 inst = $.data(cur[j], this.widgetFullName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4602 if(inst && inst !== this && !inst.options.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4603 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4604 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4605 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4606 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4607 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4608
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4609 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4611 for (i = queries.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4612 queries[i][0].each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4613 items.push(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4614 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4615 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4616
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4617 return $(items);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4618
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4619 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4620
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4621 _removeCurrentsFromItems: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4622
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4623 var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4624
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4625 this.items = $.grep(this.items, function (item) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4626 for (var j=0; j < list.length; j++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4627 if(list[j] === item.item[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4628 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4629 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4630 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4631 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4632 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4634 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4635
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4636 _refreshItems: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4638 this.items = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4639 this.containers = [this];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4640
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4641 var i, j, cur, inst, targetData, _queries, item, queriesLength,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4642 items = this.items,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4643 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4644 connectWith = this._connectWith();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4645
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4646 if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4647 for (i = connectWith.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4648 cur = $(connectWith[i]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4649 for (j = cur.length - 1; j >= 0; j--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4650 inst = $.data(cur[j], this.widgetFullName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4651 if(inst && inst !== this && !inst.options.disabled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4652 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4653 this.containers.push(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4654 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4655 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4656 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4657 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4658
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4659 for (i = queries.length - 1; i >= 0; i--) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4660 targetData = queries[i][1];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4661 _queries = queries[i][0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4662
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4663 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4664 item = $(_queries[j]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4665
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4666 item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4667
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4668 items.push({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4669 item: item,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4670 instance: targetData,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4671 width: 0, height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4672 left: 0, top: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4673 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4674 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4675 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4676
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4677 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4678
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4679 refreshPositions: function(fast) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4680
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4681 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4682 if(this.offsetParent && this.helper) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4683 this.offset.parent = this._getParentOffset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4684 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4685
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4686 var i, item, t, p;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4687
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4688 for (i = this.items.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4689 item = this.items[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4690
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4691 //We ignore calculating positions of all connected containers when we're not over them
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4692 if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4693 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4694 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4696 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4697
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4698 if (!fast) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4699 item.width = t.outerWidth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4700 item.height = t.outerHeight();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4701 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4702
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4703 p = t.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4704 item.left = p.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4705 item.top = p.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4706 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4707
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4708 if(this.options.custom && this.options.custom.refreshContainers) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4709 this.options.custom.refreshContainers.call(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4710 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4711 for (i = this.containers.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4712 p = this.containers[i].element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4713 this.containers[i].containerCache.left = p.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4714 this.containers[i].containerCache.top = p.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4715 this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4716 this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4717 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4718 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4719
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4720 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4721 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4722
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4723 _createPlaceholder: function(that) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4724 that = that || this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4725 var className,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4726 o = that.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4727
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4728 if(!o.placeholder || o.placeholder.constructor === String) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4729 className = o.placeholder;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4730 o.placeholder = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4731 element: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4733 var nodeName = that.currentItem[0].nodeName.toLowerCase(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4734 element = $( "<" + nodeName + ">", that.document[0] )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4735 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4736 .removeClass("ui-sortable-helper");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4737
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4738 if ( nodeName === "tr" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4739 that.currentItem.children().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4740 $( "<td>&#160;</td>", that.document[0] )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4741 .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4742 .appendTo( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4743 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4744 } else if ( nodeName === "img" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4745 element.attr( "src", that.currentItem.attr( "src" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4746 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4747
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4748 if ( !className ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4749 element.css( "visibility", "hidden" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4750 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4751
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4752 return element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4753 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4754 update: function(container, p) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4755
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4756 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4757 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4758 if(className && !o.forcePlaceholderSize) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4759 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4760 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4761
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4762 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4763 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4764 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4765 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4766 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4767 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4768
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4769 //Create the placeholder
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4770 that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4771
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4772 //Append it after the actual current item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4773 that.currentItem.after(that.placeholder);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4774
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4775 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4776 o.placeholder.update(that, that.placeholder);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4778 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4779
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4780 _contactContainers: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4781 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4782 innermostContainer = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4783 innermostIndex = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4784
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4785 // get innermost container that intersects with item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4786 for (i = this.containers.length - 1; i >= 0; i--) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4787
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4788 // never consider a container that's located within the item itself
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4789 if($.contains(this.currentItem[0], this.containers[i].element[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4790 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4791 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4792
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4793 if(this._intersectsWith(this.containers[i].containerCache)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4794
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4795 // if we've already found a container and it's more "inner" than this, then continue
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4796 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4797 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4798 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4799
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4800 innermostContainer = this.containers[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4801 innermostIndex = i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4802
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4803 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4804 // container doesn't intersect. trigger "out" event if necessary
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4805 if(this.containers[i].containerCache.over) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4806 this.containers[i]._trigger("out", event, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4807 this.containers[i].containerCache.over = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4808 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4809 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4810
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4811 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4812
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4813 // if no intersecting containers found, return
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4814 if(!innermostContainer) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4815 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4816 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4817
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4818 // move the item into the container if it's not there already
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4819 if(this.containers.length === 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4820 if (!this.containers[innermostIndex].containerCache.over) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4821 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4822 this.containers[innermostIndex].containerCache.over = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4823 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4824 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4825
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4826 //When entering a new container, we will find the item with the least distance and append our item near it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4827 dist = 10000;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4828 itemWithLeastDistance = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4829 floating = innermostContainer.floating || isFloating(this.currentItem);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4830 posProperty = floating ? "left" : "top";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4831 sizeProperty = floating ? "width" : "height";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4832 base = this.positionAbs[posProperty] + this.offset.click[posProperty];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4833 for (j = this.items.length - 1; j >= 0; j--) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4834 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4835 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4836 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4837 if(this.items[j].item[0] === this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4838 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4839 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4840 if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4841 continue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4842 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4843 cur = this.items[j].item.offset()[posProperty];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4844 nearBottom = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4845 if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4846 nearBottom = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4847 cur += this.items[j][sizeProperty];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4848 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4849
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4850 if(Math.abs(cur - base) < dist) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4851 dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4852 this.direction = nearBottom ? "up": "down";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4853 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4854 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4855
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4856 //Check if dropOnEmpty is enabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4857 if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4858 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4859 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4860
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4861 if(this.currentContainer === this.containers[innermostIndex]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4862 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4863 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4864
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4865 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4866 this._trigger("change", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4867 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4868 this.currentContainer = this.containers[innermostIndex];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4869
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4870 //Update the placeholder
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4871 this.options.placeholder.update(this.currentContainer, this.placeholder);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4872
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4873 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4874 this.containers[innermostIndex].containerCache.over = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4875 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4877
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4878 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4879
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4880 _createHelper: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4881
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4882 var o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4883 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4884
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4885 //Add the helper to the DOM if that didn't happen already
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4886 if(!helper.parents("body").length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4887 $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4888 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4889
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4890 if(helper[0] === this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4891 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4892 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4893
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4894 if(!helper[0].style.width || o.forceHelperSize) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4895 helper.width(this.currentItem.width());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4896 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4897 if(!helper[0].style.height || o.forceHelperSize) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4898 helper.height(this.currentItem.height());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4899 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4900
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4901 return helper;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4902
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4903 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4904
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4905 _adjustOffsetFromHelper: function(obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4906 if (typeof obj === "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4907 obj = obj.split(" ");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4908 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4909 if ($.isArray(obj)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4910 obj = {left: +obj[0], top: +obj[1] || 0};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4911 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4912 if ("left" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4913 this.offset.click.left = obj.left + this.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4914 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4915 if ("right" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4916 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4917 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4918 if ("top" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4919 this.offset.click.top = obj.top + this.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4920 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4921 if ("bottom" in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4922 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4923 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4924 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4925
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4926 _getParentOffset: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4927
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4928
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4929 //Get the offsetParent and cache its position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4930 this.offsetParent = this.helper.offsetParent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4931 var po = this.offsetParent.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4932
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4933 // This is a special case where we need to modify a offset calculated on start, since the following happened:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4934 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4935 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4936 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4937 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4938 po.left += this.scrollParent.scrollLeft();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4939 po.top += this.scrollParent.scrollTop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4940 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4941
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4942 // This needs to be actually done for all browsers, since pageX/pageY includes this information
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4943 // with an ugly IE fix
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4944 if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4945 po = { top: 0, left: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4946 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4947
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4948 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4949 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4950 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4951 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4953 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4954
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4955 _getRelativeOffset: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4956
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4957 if(this.cssPosition === "relative") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4958 var p = this.currentItem.position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4959 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4960 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4961 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4962 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4963 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4964 return { top: 0, left: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4965 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4966
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4967 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4968
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4969 _cacheMargins: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4970 this.margins = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4971 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4972 top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4973 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4974 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4975
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4976 _cacheHelperProportions: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4977 this.helperProportions = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4978 width: this.helper.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4979 height: this.helper.outerHeight()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4980 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4981 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4982
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4983 _setContainment: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4984
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4985 var ce, co, over,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4986 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4987 if(o.containment === "parent") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4988 o.containment = this.helper[0].parentNode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4989 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4990 if(o.containment === "document" || o.containment === "window") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4991 this.containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4992 0 - this.offset.relative.left - this.offset.parent.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4993 0 - this.offset.relative.top - this.offset.parent.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4994 $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4995 ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4996 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4997 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4998
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4999 if(!(/^(document|window|parent)$/).test(o.containment)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5000 ce = $(o.containment)[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5001 co = $(o.containment).offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5002 over = ($(ce).css("overflow") !== "hidden");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5003
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5004 this.containment = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5005 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5006 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5007 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5008 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5009 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5010 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5011
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5012 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5013
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5014 _convertPositionTo: function(d, pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5015
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5016 if(!pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5017 pos = this.position;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5018 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5019 var mod = d === "absolute" ? 1 : -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5020 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5021 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5022
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5023 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5024 top: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5025 pos.top + // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5026 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5027 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5028 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5029 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5030 left: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5031 pos.left + // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5032 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5033 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5034 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5035 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5036 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5037
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5038 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5039
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5040 _generatePosition: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5041
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5042 var top, left,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5043 o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5044 pageX = event.pageX,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5045 pageY = event.pageY,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5046 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5047
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5048 // This is another very weird special case that only happens for relative elements:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5049 // 1. If the css position is relative
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5050 // 2. and the scroll parent is the document or similar to the offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5051 // we have to refresh the relative offset during the scroll so there are no jumps
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5052 if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5053 this.offset.relative = this._getRelativeOffset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5054 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5055
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5056 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5057 * - Position constraining -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5058 * Constrain the position to a mix of grid, containment.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5059 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5061 if(this.originalPosition) { //If we are not dragging yet, we won't check for options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5062
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5063 if(this.containment) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5064 if(event.pageX - this.offset.click.left < this.containment[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5065 pageX = this.containment[0] + this.offset.click.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5066 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5067 if(event.pageY - this.offset.click.top < this.containment[1]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5068 pageY = this.containment[1] + this.offset.click.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5069 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5070 if(event.pageX - this.offset.click.left > this.containment[2]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5071 pageX = this.containment[2] + this.offset.click.left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5072 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5073 if(event.pageY - this.offset.click.top > this.containment[3]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5074 pageY = this.containment[3] + this.offset.click.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5075 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5076 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5077
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5078 if(o.grid) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5079 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5080 pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5081
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5082 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5083 pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5084 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5085
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5086 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5087
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5088 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5089 top: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5090 pageY - // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5091 this.offset.click.top - // Click offset (relative to the element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5092 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5093 this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5094 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5095 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5096 left: (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5097 pageX - // The absolute mouse position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5098 this.offset.click.left - // Click offset (relative to the element)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5099 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5100 this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5101 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5102 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5103 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5104
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5105 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5106
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5107 _rearrange: function(event, i, a, hardRefresh) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5108
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5109 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5110
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5111 //Various things done here to improve the performance:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5112 // 1. we create a setTimeout, that calls refreshPositions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5113 // 2. on the instance, we have a counter variable, that get's higher after every append
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5114 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5115 // 4. this lets only the last addition to the timeout stack through
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5116 this.counter = this.counter ? ++this.counter : 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5117 var counter = this.counter;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5118
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5119 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5120 if(counter === this.counter) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5121 this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5122 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5123 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5124
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5125 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5126
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5127 _clear: function(event, noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5128
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5129 this.reverting = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5130 // We delay all events that have to be triggered to after the point where the placeholder has been removed and
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5131 // everything else normalized again
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5132 var i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5133 delayedTriggers = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5134
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5135 // We first have to update the dom position of the actual currentItem
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5136 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5137 if(!this._noFinalSort && this.currentItem.parent().length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5138 this.placeholder.before(this.currentItem);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5139 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5140 this._noFinalSort = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5141
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5142 if(this.helper[0] === this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5143 for(i in this._storedCSS) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5144 if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5145 this._storedCSS[i] = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5146 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5147 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5148 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5149 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5150 this.currentItem.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5151 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5152
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5153 if(this.fromOutside && !noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5154 delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5155 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5156 if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5157 delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5159
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5160 // Check if the items Container has Changed and trigger appropriate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5161 // events.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5162 if (this !== this.currentContainer) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5163 if(!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5164 delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5165 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5166 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5167 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5168 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5169
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5170
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5171 //Post events to containers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5172 for (i = this.containers.length - 1; i >= 0; i--){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5173 if(!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5174 delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5175 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5176 if(this.containers[i].containerCache.over) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5177 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5178 this.containers[i].containerCache.over = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5179 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5180 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5181
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5182 //Do what was originally in plugins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5183 if ( this.storedCursor ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5184 this.document.find( "body" ).css( "cursor", this.storedCursor );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5185 this.storedStylesheet.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5186 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5187 if(this._storedOpacity) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5188 this.helper.css("opacity", this._storedOpacity);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5189 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5190 if(this._storedZIndex) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5191 this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5192 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5193
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5194 this.dragging = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5195 if(this.cancelHelperRemoval) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5196 if(!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5197 this._trigger("beforeStop", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5198 for (i=0; i < delayedTriggers.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5199 delayedTriggers[i].call(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5200 } //Trigger all delayed events
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5201 this._trigger("stop", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5202 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5203
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5204 this.fromOutside = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5205 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5206 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5207
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5208 if(!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5209 this._trigger("beforeStop", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5210 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5211
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5212 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5213 this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5214
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5215 if(this.helper[0] !== this.currentItem[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5216 this.helper.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5217 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5218 this.helper = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5219
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5220 if(!noPropagation) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5221 for (i=0; i < delayedTriggers.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5222 delayedTriggers[i].call(this, event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5223 } //Trigger all delayed events
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5224 this._trigger("stop", event, this._uiHash());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5225 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5226
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5227 this.fromOutside = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5228 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5229
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5230 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5231
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5232 _trigger: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5233 if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5234 this.cancel();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5235 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5236 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5237
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5238 _uiHash: function(_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5239 var inst = _inst || this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5240 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5241 helper: inst.helper,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5242 placeholder: inst.placeholder || $([]),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5243 position: inst.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5244 originalPosition: inst.originalPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5245 offset: inst.positionAbs,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5246 item: inst.currentItem,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5247 sender: _inst ? _inst.element : null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5248 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5249 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5250
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5251 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5252
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5253 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5254 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5255
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5256 var uid = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5257 hideProps = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5258 showProps = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5259
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5260 hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5261 hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5262 showProps.height = showProps.paddingTop = showProps.paddingBottom =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5263 showProps.borderTopWidth = showProps.borderBottomWidth = "show";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5264
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5265 $.widget( "ui.accordion", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5266 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5267 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5268 active: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5269 animate: {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5270 collapsible: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5271 event: "click",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5272 header: "> li > :first-child,> :not(li):even",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5273 heightStyle: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5274 icons: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5275 activeHeader: "ui-icon-triangle-1-s",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5276 header: "ui-icon-triangle-1-e"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5277 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5278
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5279 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5280 activate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5281 beforeActivate: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5282 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5283
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5284 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5285 var options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5286 this.prevShow = this.prevHide = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5287 this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5288 // ARIA
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5289 .attr( "role", "tablist" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5290
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5291 // don't allow collapsible: false and active: false / null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5292 if ( !options.collapsible && (options.active === false || options.active == null) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5293 options.active = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5294 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5295
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5296 this._processPanels();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5297 // handle negative values
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5298 if ( options.active < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5299 options.active += this.headers.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5300 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5301 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5302 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5303
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5304 _getCreateEventData: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5305 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5306 header: this.active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5307 panel: !this.active.length ? $() : this.active.next(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5308 content: !this.active.length ? $() : this.active.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5309 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5310 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5311
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5312 _createIcons: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5313 var icons = this.options.icons;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5314 if ( icons ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5315 $( "<span>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5316 .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5317 .prependTo( this.headers );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5318 this.active.children( ".ui-accordion-header-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5319 .removeClass( icons.header )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5320 .addClass( icons.activeHeader );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5321 this.headers.addClass( "ui-accordion-icons" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5322 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5323 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5324
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5325 _destroyIcons: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5326 this.headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5327 .removeClass( "ui-accordion-icons" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5328 .children( ".ui-accordion-header-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5329 .remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5330 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5331
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5332 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5333 var contents;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5334
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5335 // clean up main element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5336 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5337 .removeClass( "ui-accordion ui-widget ui-helper-reset" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5338 .removeAttr( "role" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5339
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5340 // clean up headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5341 this.headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5342 .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5343 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5344 .removeAttr( "aria-selected" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5345 .removeAttr( "aria-controls" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5346 .removeAttr( "tabIndex" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5347 .each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5348 if ( /^ui-accordion/.test( this.id ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5349 this.removeAttribute( "id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5350 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5351 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5352 this._destroyIcons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5353
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5354 // clean up content panels
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5355 contents = this.headers.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5356 .css( "display", "" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5357 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5358 .removeAttr( "aria-expanded" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5359 .removeAttr( "aria-hidden" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5360 .removeAttr( "aria-labelledby" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5361 .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5362 .each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5363 if ( /^ui-accordion/.test( this.id ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5364 this.removeAttribute( "id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5365 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5366 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5367 if ( this.options.heightStyle !== "content" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5368 contents.css( "height", "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5369 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5370 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5371
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5372 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5373 if ( key === "active" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5374 // _activate() will handle invalid values and update this.options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5375 this._activate( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5376 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5377 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5378
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5379 if ( key === "event" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5380 if ( this.options.event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5381 this._off( this.headers, this.options.event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5382 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5383 this._setupEvents( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5384 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5386 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5387
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5388 // setting collapsible: false while collapsed; open first panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5389 if ( key === "collapsible" && !value && this.options.active === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5390 this._activate( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5391 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5392
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5393 if ( key === "icons" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5394 this._destroyIcons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5395 if ( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5396 this._createIcons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5397 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5398 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5399
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5400 // #5332 - opacity doesn't cascade to positioned elements in IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5401 // so we need to add the disabled class to the headers and panels
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5402 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5403 this.headers.add( this.headers.next() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5404 .toggleClass( "ui-state-disabled", !!value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5405 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5406 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5407
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5408 _keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5409 /*jshint maxcomplexity:15*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5410 if ( event.altKey || event.ctrlKey ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5411 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5412 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5413
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5414 var keyCode = $.ui.keyCode,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5415 length = this.headers.length,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5416 currentIndex = this.headers.index( event.target ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5417 toFocus = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5418
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5419 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5420 case keyCode.RIGHT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5421 case keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5422 toFocus = this.headers[ ( currentIndex + 1 ) % length ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5423 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5424 case keyCode.LEFT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5425 case keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5426 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5427 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5428 case keyCode.SPACE:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5429 case keyCode.ENTER:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5430 this._eventHandler( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5431 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5432 case keyCode.HOME:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5433 toFocus = this.headers[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5434 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5435 case keyCode.END:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5436 toFocus = this.headers[ length - 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5437 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5438 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5439
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5440 if ( toFocus ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5441 $( event.target ).attr( "tabIndex", -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5442 $( toFocus ).attr( "tabIndex", 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5443 toFocus.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5444 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5445 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5446 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5447
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5448 _panelKeyDown : function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5449 if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5450 $( event.currentTarget ).prev().focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5451 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5452 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5453
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5454 refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5455 var options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5456 this._processPanels();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5457
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5458 // was collapsed or no panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5459 if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5460 options.active = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5461 this.active = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5462 // active false only when collapsible is true
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5463 } else if ( options.active === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5464 this._activate( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5465 // was active, but active panel is gone
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5466 } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5467 // all remaining panel are disabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5468 if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5469 options.active = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5470 this.active = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5471 // activate previous panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5472 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5473 this._activate( Math.max( 0, options.active - 1 ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5474 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5475 // was active, active panel still exists
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5476 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5477 // make sure active index is correct
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5478 options.active = this.headers.index( this.active );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5479 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5480
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5481 this._destroyIcons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5482
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5483 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5484 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5485
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5486 _processPanels: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5487 this.headers = this.element.find( this.options.header )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5488 .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5489
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5490 this.headers.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5491 .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5492 .filter(":not(.ui-accordion-content-active)")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5493 .hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5494 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5495
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5496 _refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5497 var maxHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5498 options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5499 heightStyle = options.heightStyle,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5500 parent = this.element.parent(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5501 accordionId = this.accordionId = "ui-accordion-" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5502 (this.element.attr( "id" ) || ++uid);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5503
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5504 this.active = this._findActive( options.active )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5505 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5506 .removeClass( "ui-corner-all" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5507 this.active.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5508 .addClass( "ui-accordion-content-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5509 .show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5510
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5511 this.headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5512 .attr( "role", "tab" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5513 .each(function( i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5514 var header = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5515 headerId = header.attr( "id" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5516 panel = header.next(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5517 panelId = panel.attr( "id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5518 if ( !headerId ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5519 headerId = accordionId + "-header-" + i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5520 header.attr( "id", headerId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5521 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5522 if ( !panelId ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5523 panelId = accordionId + "-panel-" + i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5524 panel.attr( "id", panelId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5525 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5526 header.attr( "aria-controls", panelId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5527 panel.attr( "aria-labelledby", headerId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5528 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5529 .next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5530 .attr( "role", "tabpanel" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5531
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5532 this.headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5533 .not( this.active )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5534 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5535 "aria-selected": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5536 tabIndex: -1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5537 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5538 .next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5539 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5540 "aria-expanded": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5541 "aria-hidden": "true"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5542 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5543 .hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5544
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5545 // make sure at least one header is in the tab order
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5546 if ( !this.active.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5547 this.headers.eq( 0 ).attr( "tabIndex", 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5548 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5549 this.active.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5550 "aria-selected": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5551 tabIndex: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5552 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5553 .next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5554 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5555 "aria-expanded": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5556 "aria-hidden": "false"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5557 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5558 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5560 this._createIcons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5561
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5562 this._setupEvents( options.event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5563
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5564 if ( heightStyle === "fill" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5565 maxHeight = parent.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5566 this.element.siblings( ":visible" ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5567 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5568 position = elem.css( "position" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5569
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5570 if ( position === "absolute" || position === "fixed" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5571 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5572 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5573 maxHeight -= elem.outerHeight( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5574 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5575
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5576 this.headers.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5577 maxHeight -= $( this ).outerHeight( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5578 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5579
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5580 this.headers.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5581 .each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5582 $( this ).height( Math.max( 0, maxHeight -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5583 $( this ).innerHeight() + $( this ).height() ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5584 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5585 .css( "overflow", "auto" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5586 } else if ( heightStyle === "auto" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5587 maxHeight = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5588 this.headers.next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5589 .each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5590 maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5591 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5592 .height( maxHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5593 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5594 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5595
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5596 _activate: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5597 var active = this._findActive( index )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5598
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5599 // trying to activate the already active panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5600 if ( active === this.active[ 0 ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5601 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5602 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5603
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5604 // trying to collapse, simulate a click on the currently active header
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5605 active = active || this.active[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5606
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5607 this._eventHandler({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5608 target: active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5609 currentTarget: active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5610 preventDefault: $.noop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5611 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5612 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5613
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5614 _findActive: function( selector ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5615 return typeof selector === "number" ? this.headers.eq( selector ) : $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5616 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5617
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5618 _setupEvents: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5619 var events = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5620 keydown: "_keydown"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5621 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5622 if ( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5623 $.each( event.split(" "), function( index, eventName ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5624 events[ eventName ] = "_eventHandler";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5625 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5626 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5627
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5628 this._off( this.headers.add( this.headers.next() ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5629 this._on( this.headers, events );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5630 this._on( this.headers.next(), { keydown: "_panelKeyDown" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5631 this._hoverable( this.headers );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5632 this._focusable( this.headers );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5633 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5634
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5635 _eventHandler: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5636 var options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5637 active = this.active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5638 clicked = $( event.currentTarget ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5639 clickedIsActive = clicked[ 0 ] === active[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5640 collapsing = clickedIsActive && options.collapsible,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5641 toShow = collapsing ? $() : clicked.next(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5642 toHide = active.next(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5643 eventData = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5644 oldHeader: active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5645 oldPanel: toHide,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5646 newHeader: collapsing ? $() : clicked,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5647 newPanel: toShow
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5648 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5649
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5650 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5651
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5652 if (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5653 // click on active header, but not collapsible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5654 ( clickedIsActive && !options.collapsible ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5655 // allow canceling activation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5656 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5657 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5658 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5659
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5660 options.active = collapsing ? false : this.headers.index( clicked );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5661
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5662 // when the call to ._toggle() comes after the class changes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5663 // it causes a very odd bug in IE 8 (see #6720)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5664 this.active = clickedIsActive ? $() : clicked;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5665 this._toggle( eventData );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5666
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5667 // switch classes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5668 // corner classes on the previously active header stay after the animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5669 active.removeClass( "ui-accordion-header-active ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5670 if ( options.icons ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5671 active.children( ".ui-accordion-header-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5672 .removeClass( options.icons.activeHeader )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5673 .addClass( options.icons.header );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5674 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5675
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5676 if ( !clickedIsActive ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5677 clicked
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5678 .removeClass( "ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5679 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5680 if ( options.icons ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5681 clicked.children( ".ui-accordion-header-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5682 .removeClass( options.icons.header )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5683 .addClass( options.icons.activeHeader );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5684 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5685
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5686 clicked
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5687 .next()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5688 .addClass( "ui-accordion-content-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5689 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5690 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5691
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5692 _toggle: function( data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5693 var toShow = data.newPanel,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5694 toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5696 // handle activating a panel during the animation for another activation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5697 this.prevShow.add( this.prevHide ).stop( true, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5698 this.prevShow = toShow;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5699 this.prevHide = toHide;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5700
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5701 if ( this.options.animate ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5702 this._animate( toShow, toHide, data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5703 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5704 toHide.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5705 toShow.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5706 this._toggleComplete( data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5707 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5708
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5709 toHide.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5710 "aria-expanded": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5711 "aria-hidden": "true"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5712 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5713 toHide.prev().attr( "aria-selected", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5714 // if we're switching panels, remove the old header from the tab order
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5715 // if we're opening from collapsed state, remove the previous header from the tab order
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5716 // if we're collapsing, then keep the collapsing header in the tab order
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5717 if ( toShow.length && toHide.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5718 toHide.prev().attr( "tabIndex", -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5719 } else if ( toShow.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5720 this.headers.filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5721 return $( this ).attr( "tabIndex" ) === 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5722 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5723 .attr( "tabIndex", -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5724 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5725
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5726 toShow
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5727 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5728 "aria-expanded": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5729 "aria-hidden": "false"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5730 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5731 .prev()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5732 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5733 "aria-selected": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5734 tabIndex: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5735 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5736 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5737
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5738 _animate: function( toShow, toHide, data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5739 var total, easing, duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5740 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5741 adjust = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5742 down = toShow.length &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5743 ( !toHide.length || ( toShow.index() < toHide.index() ) ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5744 animate = this.options.animate || {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5745 options = down && animate.down || animate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5746 complete = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5747 that._toggleComplete( data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5748 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5749
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5750 if ( typeof options === "number" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5751 duration = options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5752 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5753 if ( typeof options === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5754 easing = options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5755 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5756 // fall back from options to animation in case of partial down settings
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5757 easing = easing || options.easing || animate.easing;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5758 duration = duration || options.duration || animate.duration;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5759
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5760 if ( !toHide.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5761 return toShow.animate( showProps, duration, easing, complete );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5762 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5763 if ( !toShow.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5764 return toHide.animate( hideProps, duration, easing, complete );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5765 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5766
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5767 total = toShow.show().outerHeight();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5768 toHide.animate( hideProps, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5769 duration: duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5770 easing: easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5771 step: function( now, fx ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5772 fx.now = Math.round( now );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5773 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5774 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5775 toShow
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5776 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5777 .animate( showProps, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5778 duration: duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5779 easing: easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5780 complete: complete,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5781 step: function( now, fx ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5782 fx.now = Math.round( now );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5783 if ( fx.prop !== "height" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5784 adjust += fx.now;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5785 } else if ( that.options.heightStyle !== "content" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5786 fx.now = Math.round( total - toHide.outerHeight() - adjust );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5787 adjust = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5788 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5789 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5790 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5791 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5792
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5793 _toggleComplete: function( data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5794 var toHide = data.oldPanel;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5795
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5796 toHide
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5797 .removeClass( "ui-accordion-content-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5798 .prev()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5799 .removeClass( "ui-corner-top" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5800 .addClass( "ui-corner-all" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5801
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5802 // Work around for rendering bug in IE (#5421)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5803 if ( toHide.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5804 toHide.parent()[0].className = toHide.parent()[0].className;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5805 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5806
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5807 this._trigger( "activate", null, data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5808 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5809 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5810
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5811 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5812 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5813
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5814 // used to prevent race conditions with remote data sources
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5815 var requestIndex = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5816
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5817 $.widget( "ui.autocomplete", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5818 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5819 defaultElement: "<input>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5820 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5821 appendTo: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5822 autoFocus: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5823 delay: 300,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5824 minLength: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5825 position: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5826 my: "left top",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5827 at: "left bottom",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5828 collision: "none"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5829 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5830 source: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5831
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5832 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5833 change: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5834 close: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5835 focus: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5836 open: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5837 response: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5838 search: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5839 select: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5840 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5841
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5842 pending: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5843
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5844 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5845 // Some browsers only repeat keydown events, not keypress events,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5846 // so we use the suppressKeyPress flag to determine if we've already
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5847 // handled the keydown event. #7269
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5848 // Unfortunately the code for & in keypress is the same as the up arrow,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5849 // so we use the suppressKeyPressRepeat flag to avoid handling keypress
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5850 // events when we know the keydown event was used to modify the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5851 // search term. #7799
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5852 var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5853 nodeName = this.element[0].nodeName.toLowerCase(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5854 isTextarea = nodeName === "textarea",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5855 isInput = nodeName === "input";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5856
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5857 this.isMultiLine =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5858 // Textareas are always multi-line
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5859 isTextarea ? true :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5860 // Inputs are always single-line, even if inside a contentEditable element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5861 // IE also treats inputs as contentEditable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5862 isInput ? false :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5863 // All other element types are determined by whether or not they're contentEditable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5864 this.element.prop( "isContentEditable" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5865
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5866 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5867 this.isNewMenu = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5868
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5869 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5870 .addClass( "ui-autocomplete-input" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5871 .attr( "autocomplete", "off" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5872
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5873 this._on( this.element, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5874 keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5875 /*jshint maxcomplexity:15*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5876 if ( this.element.prop( "readOnly" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5877 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5878 suppressInput = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5879 suppressKeyPressRepeat = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5880 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5881 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5882
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5883 suppressKeyPress = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5884 suppressInput = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5885 suppressKeyPressRepeat = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5886 var keyCode = $.ui.keyCode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5887 switch( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5888 case keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5889 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5890 this._move( "previousPage", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5891 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5892 case keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5893 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5894 this._move( "nextPage", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5895 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5896 case keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5897 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5898 this._keyEvent( "previous", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5899 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5900 case keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5901 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5902 this._keyEvent( "next", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5903 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5904 case keyCode.ENTER:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5905 case keyCode.NUMPAD_ENTER:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5906 // when menu is open and has focus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5907 if ( this.menu.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5908 // #6055 - Opera still allows the keypress to occur
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5909 // which causes forms to submit
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5910 suppressKeyPress = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5911 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5912 this.menu.select( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5913 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5914 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5915 case keyCode.TAB:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5916 if ( this.menu.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5917 this.menu.select( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5918 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5919 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5920 case keyCode.ESCAPE:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5921 if ( this.menu.element.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5922 this._value( this.term );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5923 this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5924 // Different browsers have different default behavior for escape
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5925 // Single press can mean undo or clear
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5926 // Double press in IE means clear the whole form
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5927 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5928 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5929 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5930 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5931 suppressKeyPressRepeat = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5932 // search timeout should be triggered before the input value is changed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5933 this._searchTimeout( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5934 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5935 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5936 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5937 keypress: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5938 if ( suppressKeyPress ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5939 suppressKeyPress = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5940 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5941 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5942 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5943 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5944 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5945 if ( suppressKeyPressRepeat ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5946 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5947 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5948
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5949 // replicate some key handlers to allow them to repeat in Firefox and Opera
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5950 var keyCode = $.ui.keyCode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5951 switch( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5952 case keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5953 this._move( "previousPage", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5954 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5955 case keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5956 this._move( "nextPage", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5957 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5958 case keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5959 this._keyEvent( "previous", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5960 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5961 case keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5962 this._keyEvent( "next", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5963 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5964 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5965 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5966 input: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5967 if ( suppressInput ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5968 suppressInput = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5969 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5970 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5971 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5972 this._searchTimeout( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5973 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5974 focus: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5975 this.selectedItem = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5976 this.previous = this._value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5977 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5978 blur: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5979 if ( this.cancelBlur ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5980 delete this.cancelBlur;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5981 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5982 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5983
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5984 clearTimeout( this.searching );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5985 this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5986 this._change( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5987 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5988 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5989
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5990 this._initSource();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5991 this.menu = $( "<ul>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5992 .addClass( "ui-autocomplete ui-front" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5993 .appendTo( this._appendTo() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5994 .menu({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5995 // disable ARIA support, the live region takes care of that
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5996 role: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5997 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5998 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5999 .data( "ui-menu" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6000
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6001 this._on( this.menu.element, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6002 mousedown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6003 // prevent moving focus out of the text field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6004 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6005
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6006 // IE doesn't prevent moving focus even with event.preventDefault()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6007 // so we set a flag to know when we should ignore the blur event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6008 this.cancelBlur = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6009 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6010 delete this.cancelBlur;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6011 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6012
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6013 // clicking on the scrollbar causes focus to shift to the body
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6014 // but we can't detect a mouseup or a click immediately afterward
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6015 // so we have to track the next mousedown and close the menu if
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6016 // the user clicks somewhere outside of the autocomplete
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6017 var menuElement = this.menu.element[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6018 if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6019 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6020 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6021 this.document.one( "mousedown", function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6022 if ( event.target !== that.element[ 0 ] &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6023 event.target !== menuElement &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6024 !$.contains( menuElement, event.target ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6025 that.close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6026 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6027 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6028 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6029 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6030 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6031 menufocus: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6032 // support: Firefox
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6033 // Prevent accidental activation of menu items in Firefox (#7024 #9118)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6034 if ( this.isNewMenu ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6035 this.isNewMenu = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6036 if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6037 this.menu.blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6038
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6039 this.document.one( "mousemove", function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6040 $( event.target ).trigger( event.originalEvent );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6041 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6042
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6043 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6044 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6045 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6046
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6047 var item = ui.item.data( "ui-autocomplete-item" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6048 if ( false !== this._trigger( "focus", event, { item: item } ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6049 // use value to match what will end up in the input, if it was a key event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6050 if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6051 this._value( item.value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6052 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6053 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6054 // Normally the input is populated with the item's value as the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6055 // menu is navigated, causing screen readers to notice a change and
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6056 // announce the item. Since the focus event was canceled, this doesn't
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6057 // happen, so we update the live region so that screen readers can
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6058 // still notice the change and announce it.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6059 this.liveRegion.text( item.value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6060 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6061 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6062 menuselect: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6063 var item = ui.item.data( "ui-autocomplete-item" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6064 previous = this.previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6065
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6066 // only trigger when focus was lost (click on menu)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6067 if ( this.element[0] !== this.document[0].activeElement ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6068 this.element.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6069 this.previous = previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6070 // #6109 - IE triggers two focus events and the second
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6071 // is asynchronous, so we need to reset the previous
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6072 // term synchronously and asynchronously :-(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6073 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6074 this.previous = previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6075 this.selectedItem = item;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6076 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6077 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6078
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6079 if ( false !== this._trigger( "select", event, { item: item } ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6080 this._value( item.value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6081 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6082 // reset the term after the select event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6083 // this allows custom select handling to work properly
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6084 this.term = this._value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6085
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6086 this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6087 this.selectedItem = item;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6088 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6089 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6090
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6091 this.liveRegion = $( "<span>", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6092 role: "status",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6093 "aria-live": "polite"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6094 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6095 .addClass( "ui-helper-hidden-accessible" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6096 .insertBefore( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6097
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6098 // turning off autocomplete prevents the browser from remembering the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6099 // value when navigating through history, so we re-enable autocomplete
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6100 // if the page is unloaded before the widget is destroyed. #7790
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6101 this._on( this.window, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6102 beforeunload: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6103 this.element.removeAttr( "autocomplete" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6104 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6105 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6106 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6107
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6108 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6109 clearTimeout( this.searching );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6110 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6111 .removeClass( "ui-autocomplete-input" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6112 .removeAttr( "autocomplete" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6113 this.menu.element.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6114 this.liveRegion.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6115 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6116
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6117 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6118 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6119 if ( key === "source" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6120 this._initSource();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6121 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6122 if ( key === "appendTo" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6123 this.menu.element.appendTo( this._appendTo() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6124 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6125 if ( key === "disabled" && value && this.xhr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6126 this.xhr.abort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6127 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6128 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6129
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6130 _appendTo: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6131 var element = this.options.appendTo;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6132
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6133 if ( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6134 element = element.jquery || element.nodeType ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6135 $( element ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6136 this.document.find( element ).eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6137 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6138
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6139 if ( !element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6140 element = this.element.closest( ".ui-front" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6141 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6142
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6143 if ( !element.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6144 element = this.document[0].body;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6145 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6146
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6147 return element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6148 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6149
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6150 _initSource: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6151 var array, url,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6152 that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6153 if ( $.isArray(this.options.source) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6154 array = this.options.source;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6155 this.source = function( request, response ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6156 response( $.ui.autocomplete.filter( array, request.term ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6157 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6158 } else if ( typeof this.options.source === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6159 url = this.options.source;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6160 this.source = function( request, response ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6161 if ( that.xhr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6162 that.xhr.abort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6163 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6164 that.xhr = $.ajax({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6165 url: url,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6166 data: request,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6167 dataType: "json",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6168 success: function( data ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6169 response( data );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6170 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6171 error: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6172 response( [] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6173 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6174 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6175 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6176 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6177 this.source = this.options.source;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6178 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6179 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6180
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6181 _searchTimeout: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6182 clearTimeout( this.searching );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6183 this.searching = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6184 // only search if the value has changed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6185 if ( this.term !== this._value() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6186 this.selectedItem = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6187 this.search( null, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6188 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6189 }, this.options.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6190 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6191
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6192 search: function( value, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6193 value = value != null ? value : this._value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6194
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6195 // always save the actual value, not the one passed as an argument
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6196 this.term = this._value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6197
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6198 if ( value.length < this.options.minLength ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6199 return this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6200 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6201
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6202 if ( this._trigger( "search", event ) === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6203 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6204 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6205
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6206 return this._search( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6207 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6208
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6209 _search: function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6210 this.pending++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6211 this.element.addClass( "ui-autocomplete-loading" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6212 this.cancelSearch = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6213
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6214 this.source( { term: value }, this._response() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6215 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6216
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6217 _response: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6218 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6219 index = ++requestIndex;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6220
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6221 return function( content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6222 if ( index === requestIndex ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6223 that.__response( content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6224 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6225
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6226 that.pending--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6227 if ( !that.pending ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6228 that.element.removeClass( "ui-autocomplete-loading" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6229 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6230 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6231 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6232
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6233 __response: function( content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6234 if ( content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6235 content = this._normalize( content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6236 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6237 this._trigger( "response", null, { content: content } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6238 if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6239 this._suggest( content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6240 this._trigger( "open" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6241 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6242 // use ._close() instead of .close() so we don't cancel future searches
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6243 this._close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6244 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6245 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6246
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6247 close: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6248 this.cancelSearch = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6249 this._close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6250 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6251
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6252 _close: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6253 if ( this.menu.element.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6254 this.menu.element.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6255 this.menu.blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6256 this.isNewMenu = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6257 this._trigger( "close", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6258 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6259 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6260
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6261 _change: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6262 if ( this.previous !== this._value() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6263 this._trigger( "change", event, { item: this.selectedItem } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6264 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6265 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6266
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6267 _normalize: function( items ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6268 // assume all items have the right format when the first item is complete
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6269 if ( items.length && items[0].label && items[0].value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6270 return items;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6271 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6272 return $.map( items, function( item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6273 if ( typeof item === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6274 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6275 label: item,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6276 value: item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6277 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6278 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6279 return $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6280 label: item.label || item.value,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6281 value: item.value || item.label
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6282 }, item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6283 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6284 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6285
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6286 _suggest: function( items ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6287 var ul = this.menu.element.empty();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6288 this._renderMenu( ul, items );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6289 this.isNewMenu = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6290 this.menu.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6291
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6292 // size and position menu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6293 ul.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6294 this._resizeMenu();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6295 ul.position( $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6296 of: this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6297 }, this.options.position ));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6298
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6299 if ( this.options.autoFocus ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6300 this.menu.next();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6301 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6302 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6303
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6304 _resizeMenu: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6305 var ul = this.menu.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6306 ul.outerWidth( Math.max(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6307 // Firefox wraps long text (possibly a rounding bug)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6308 // so we add 1px to avoid the wrapping (#7513)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6309 ul.width( "" ).outerWidth() + 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6310 this.element.outerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6311 ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6312 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6313
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6314 _renderMenu: function( ul, items ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6315 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6316 $.each( items, function( index, item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6317 that._renderItemData( ul, item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6318 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6319 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6320
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6321 _renderItemData: function( ul, item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6322 return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6323 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6324
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6325 _renderItem: function( ul, item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6326 return $( "<li>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6327 .append( $( "<a>" ).text( item.label ) )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6328 .appendTo( ul );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6329 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6331 _move: function( direction, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6332 if ( !this.menu.element.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6333 this.search( null, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6334 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6335 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6336 if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6337 this.menu.isLastItem() && /^next/.test( direction ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6338 this._value( this.term );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6339 this.menu.blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6340 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6341 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6342 this.menu[ direction ]( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6343 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6344
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6345 widget: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6346 return this.menu.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6347 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6348
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6349 _value: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6350 return this.valueMethod.apply( this.element, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6351 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6352
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6353 _keyEvent: function( keyEvent, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6354 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6355 this._move( keyEvent, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6356
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6357 // prevents moving cursor to beginning/end of the text field in some browsers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6358 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6359 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6360 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6361 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6362
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6363 $.extend( $.ui.autocomplete, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6364 escapeRegex: function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6365 return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6366 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6367 filter: function(array, term) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6368 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6369 return $.grep( array, function(value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6370 return matcher.test( value.label || value.value || value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6371 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6372 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6373 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6374
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6375
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6376 // live region extension, adding a `messages` option
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6377 // NOTE: This is an experimental API. We are still investigating
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6378 // a full solution for string manipulation and internationalization.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6379 $.widget( "ui.autocomplete", $.ui.autocomplete, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6380 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6381 messages: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6382 noResults: "No search results.",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6383 results: function( amount ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6384 return amount + ( amount > 1 ? " results are" : " result is" ) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6385 " available, use up and down arrow keys to navigate.";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6386 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6387 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6388 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6389
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6390 __response: function( content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6391 var message;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6392 this._superApply( arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6393 if ( this.options.disabled || this.cancelSearch ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6394 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6395 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6396 if ( content && content.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6397 message = this.options.messages.results( content.length );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6398 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6399 message = this.options.messages.noResults;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6400 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6401 this.liveRegion.text( message );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6402 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6403 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6404
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6405 }( jQuery ));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6406 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6407
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6408 var lastActive, startXPos, startYPos, clickDragged,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6409 baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6410 stateClasses = "ui-state-hover ui-state-active ",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6411 typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6412 formResetHandler = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6413 var form = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6414 setTimeout(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6415 form.find( ":ui-button" ).button( "refresh" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6416 }, 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6417 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6418 radioGroup = function( radio ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6419 var name = radio.name,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6420 form = radio.form,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6421 radios = $( [] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6422 if ( name ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6423 name = name.replace( /'/g, "\\'" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6424 if ( form ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6425 radios = $( form ).find( "[name='" + name + "']" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6426 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6427 radios = $( "[name='" + name + "']", radio.ownerDocument )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6428 .filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6429 return !this.form;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6430 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6431 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6432 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6433 return radios;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6434 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6435
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6436 $.widget( "ui.button", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6437 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6438 defaultElement: "<button>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6439 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6440 disabled: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6441 text: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6442 label: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6443 icons: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6444 primary: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6445 secondary: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6446 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6447 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6448 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6449 this.element.closest( "form" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6450 .unbind( "reset" + this.eventNamespace )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6451 .bind( "reset" + this.eventNamespace, formResetHandler );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6452
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6453 if ( typeof this.options.disabled !== "boolean" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6454 this.options.disabled = !!this.element.prop( "disabled" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6455 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6456 this.element.prop( "disabled", this.options.disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6457 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6458
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6459 this._determineButtonType();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6460 this.hasTitle = !!this.buttonElement.attr( "title" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6461
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6462 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6463 options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6464 toggleButton = this.type === "checkbox" || this.type === "radio",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6465 activeClass = !toggleButton ? "ui-state-active" : "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6466 focusClass = "ui-state-focus";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6467
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6468 if ( options.label === null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6469 options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6470 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6471
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6472 this._hoverable( this.buttonElement );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6473
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6474 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6475 .addClass( baseClasses )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6476 .attr( "role", "button" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6477 .bind( "mouseenter" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6478 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6479 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6480 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6481 if ( this === lastActive ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6482 $( this ).addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6483 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6484 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6485 .bind( "mouseleave" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6486 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6487 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6489 $( this ).removeClass( activeClass );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6490 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6491 .bind( "click" + this.eventNamespace, function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6492 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6493 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6494 event.stopImmediatePropagation();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6495 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6496 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6497
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6498 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6499 .bind( "focus" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6500 // no need to check disabled, focus won't be triggered anyway
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6501 that.buttonElement.addClass( focusClass );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6502 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6503 .bind( "blur" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6504 that.buttonElement.removeClass( focusClass );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6505 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6506
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6507 if ( toggleButton ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6508 this.element.bind( "change" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6509 if ( clickDragged ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6510 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6511 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6512 that.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6513 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6514 // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6515 // prevents issue where button state changes but checkbox/radio checked state
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6516 // does not in Firefox (see ticket #6970)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6517 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6518 .bind( "mousedown" + this.eventNamespace, function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6519 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6520 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6521 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6522 clickDragged = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6523 startXPos = event.pageX;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6524 startYPos = event.pageY;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6525 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6526 .bind( "mouseup" + this.eventNamespace, function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6527 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6528 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6529 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6530 if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6531 clickDragged = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6532 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6533 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6534 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6536 if ( this.type === "checkbox" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6537 this.buttonElement.bind( "click" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6538 if ( options.disabled || clickDragged ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6539 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6540 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6541 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6542 } else if ( this.type === "radio" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6543 this.buttonElement.bind( "click" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6544 if ( options.disabled || clickDragged ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6545 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6546 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6547 $( this ).addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6548 that.buttonElement.attr( "aria-pressed", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6549
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6550 var radio = that.element[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6551 radioGroup( radio )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6552 .not( radio )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6553 .map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6554 return $( this ).button( "widget" )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6555 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6556 .removeClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6557 .attr( "aria-pressed", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6558 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6559 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6560 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6561 .bind( "mousedown" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6562 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6563 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6564 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6565 $( this ).addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6566 lastActive = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6567 that.document.one( "mouseup", function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6568 lastActive = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6569 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6570 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6571 .bind( "mouseup" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6572 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6573 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6574 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6575 $( this ).removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6576 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6577 .bind( "keydown" + this.eventNamespace, function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6578 if ( options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6579 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6580 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6581 if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6582 $( this ).addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6583 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6584 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6585 // see #8559, we bind to blur here in case the button element loses
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6586 // focus between keydown and keyup, it would be left in an "active" state
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6587 .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6588 $( this ).removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6589 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6590
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6591 if ( this.buttonElement.is("a") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6592 this.buttonElement.keyup(function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6593 if ( event.keyCode === $.ui.keyCode.SPACE ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6594 // TODO pass through original event correctly (just as 2nd argument doesn't work)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6595 $( this ).click();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6596 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6597 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6598 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6599 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6600
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6601 // TODO: pull out $.Widget's handling for the disabled option into
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6602 // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6603 // be overridden by individual plugins
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6604 this._setOption( "disabled", options.disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6605 this._resetButton();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6606 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6607
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6608 _determineButtonType: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6609 var ancestor, labelSelector, checked;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6611 if ( this.element.is("[type=checkbox]") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6612 this.type = "checkbox";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6613 } else if ( this.element.is("[type=radio]") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6614 this.type = "radio";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6615 } else if ( this.element.is("input") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6616 this.type = "input";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6617 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6618 this.type = "button";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6619 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6620
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6621 if ( this.type === "checkbox" || this.type === "radio" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6622 // we don't search against the document in case the element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6623 // is disconnected from the DOM
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6624 ancestor = this.element.parents().last();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6625 labelSelector = "label[for='" + this.element.attr("id") + "']";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6626 this.buttonElement = ancestor.find( labelSelector );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6627 if ( !this.buttonElement.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6628 ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6629 this.buttonElement = ancestor.filter( labelSelector );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6630 if ( !this.buttonElement.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6631 this.buttonElement = ancestor.find( labelSelector );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6632 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6633 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6634 this.element.addClass( "ui-helper-hidden-accessible" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6635
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6636 checked = this.element.is( ":checked" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6637 if ( checked ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6638 this.buttonElement.addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6639 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6640 this.buttonElement.prop( "aria-pressed", checked );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6641 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6642 this.buttonElement = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6643 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6644 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6645
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6646 widget: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6647 return this.buttonElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6648 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6649
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6650 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6651 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6652 .removeClass( "ui-helper-hidden-accessible" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6653 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6654 .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6655 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6656 .removeAttr( "aria-pressed" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6657 .html( this.buttonElement.find(".ui-button-text").html() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6658
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6659 if ( !this.hasTitle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6660 this.buttonElement.removeAttr( "title" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6661 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6662 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6663
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6664 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6665 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6666 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6667 if ( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6668 this.element.prop( "disabled", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6669 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6670 this.element.prop( "disabled", false );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6671 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6672 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6673 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6674 this._resetButton();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6675 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6676
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6677 refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6678 //See #8237 & #8828
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6679 var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6680
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6681 if ( isDisabled !== this.options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6682 this._setOption( "disabled", isDisabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6683 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6684 if ( this.type === "radio" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6685 radioGroup( this.element[0] ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6686 if ( $( this ).is( ":checked" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6687 $( this ).button( "widget" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6688 .addClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6689 .attr( "aria-pressed", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6690 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6691 $( this ).button( "widget" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6692 .removeClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6693 .attr( "aria-pressed", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6694 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6695 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6696 } else if ( this.type === "checkbox" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6697 if ( this.element.is( ":checked" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6698 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6699 .addClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6700 .attr( "aria-pressed", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6701 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6702 this.buttonElement
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6703 .removeClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6704 .attr( "aria-pressed", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6705 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6706 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6707 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6708
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6709 _resetButton: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6710 if ( this.type === "input" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6711 if ( this.options.label ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6712 this.element.val( this.options.label );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6713 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6714 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6715 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6716 var buttonElement = this.buttonElement.removeClass( typeClasses ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6717 buttonText = $( "<span></span>", this.document[0] )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6718 .addClass( "ui-button-text" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6719 .html( this.options.label )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6720 .appendTo( buttonElement.empty() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6721 .text(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6722 icons = this.options.icons,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6723 multipleIcons = icons.primary && icons.secondary,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6724 buttonClasses = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6725
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6726 if ( icons.primary || icons.secondary ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6727 if ( this.options.text ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6728 buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6729 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6730
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6731 if ( icons.primary ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6732 buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6733 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6734
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6735 if ( icons.secondary ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6736 buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6737 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6738
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6739 if ( !this.options.text ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6740 buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6741
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6742 if ( !this.hasTitle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6743 buttonElement.attr( "title", $.trim( buttonText ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6745 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6746 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6747 buttonClasses.push( "ui-button-text-only" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6748 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6749 buttonElement.addClass( buttonClasses.join( " " ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6750 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6751 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6752
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6753 $.widget( "ui.buttonset", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6754 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6755 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6756 items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6757 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6758
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6759 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6760 this.element.addClass( "ui-buttonset" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6761 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6762
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6763 _init: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6764 this.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6765 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6766
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6767 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6768 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6769 this.buttons.button( "option", key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6770 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6771
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6772 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6773 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6774
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6775 refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6776 var rtl = this.element.css( "direction" ) === "rtl";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6778 this.buttons = this.element.find( this.options.items )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6779 .filter( ":ui-button" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6780 .button( "refresh" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6781 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6782 .not( ":ui-button" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6783 .button()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6784 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6785 .map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6786 return $( this ).button( "widget" )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6787 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6788 .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6789 .filter( ":first" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6790 .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6791 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6792 .filter( ":last" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6793 .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6794 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6795 .end();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6796 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6797
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6798 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6799 this.element.removeClass( "ui-buttonset" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6800 this.buttons
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6801 .map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6802 return $( this ).button( "widget" )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6803 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6804 .removeClass( "ui-corner-left ui-corner-right" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6805 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6806 .button( "destroy" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6807 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6808 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6809
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6810 }( jQuery ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6811 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6812
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6813 $.extend($.ui, { datepicker: { version: "1.10.3" } });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6814
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6815 var PROP_NAME = "datepicker",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6816 instActive;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6817
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6818 /* Date picker manager.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6819 Use the singleton instance of this class, $.datepicker, to interact with the date picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6820 Settings for (groups of) date pickers are maintained in an instance object,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6821 allowing multiple different settings on the same page. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6823 function Datepicker() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6824 this._curInst = null; // The current instance in use
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6825 this._keyEvent = false; // If the last event was a key event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6826 this._disabledInputs = []; // List of date picker inputs that have been disabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6827 this._datepickerShowing = false; // True if the popup picker is showing , false if not
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6828 this._inDialog = false; // True if showing within a "dialog", false if not
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6829 this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6830 this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6831 this._appendClass = "ui-datepicker-append"; // The name of the append marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6832 this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6833 this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6834 this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6835 this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6836 this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6837 this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6838 this.regional = []; // Available regional settings, indexed by language code
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6839 this.regional[""] = { // Default regional settings
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6840 closeText: "Done", // Display text for close link
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6841 prevText: "Prev", // Display text for previous month link
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6842 nextText: "Next", // Display text for next month link
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6843 currentText: "Today", // Display text for current month link
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6844 monthNames: ["January","February","March","April","May","June",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6845 "July","August","September","October","November","December"], // Names of months for drop-down and formatting
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6846 monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6847 dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6848 dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6849 dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6850 weekHeader: "Wk", // Column header for week of the year
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6851 dateFormat: "mm/dd/yy", // See format options on parseDate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6852 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6853 isRTL: false, // True if right-to-left language, false if left-to-right
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6854 showMonthAfterYear: false, // True if the year select precedes month, false for month then year
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6855 yearSuffix: "" // Additional text to append to the year in the month headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6856 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6857 this._defaults = { // Global defaults for all the date picker instances
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6858 showOn: "focus", // "focus" for popup on focus,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6859 // "button" for trigger button, or "both" for either
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6860 showAnim: "fadeIn", // Name of jQuery animation for popup
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6861 showOptions: {}, // Options for enhanced animations
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6862 defaultDate: null, // Used when field is blank: actual date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6863 // +/-number for offset from today, null for today
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6864 appendText: "", // Display text following the input box, e.g. showing the format
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6865 buttonText: "...", // Text for trigger button
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6866 buttonImage: "", // URL for trigger button image
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6867 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6868 hideIfNoPrevNext: false, // True to hide next/previous month links
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6869 // if not applicable, false to just disable them
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6870 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6871 gotoCurrent: false, // True if today link goes back to current selection instead
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6872 changeMonth: false, // True if month can be selected directly, false if only prev/next
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6873 changeYear: false, // True if year can be selected directly, false if only prev/next
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6874 yearRange: "c-10:c+10", // Range of years to display in drop-down,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6875 // either relative to today's year (-nn:+nn), relative to currently displayed year
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6876 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6877 showOtherMonths: false, // True to show dates in other months, false to leave blank
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6878 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6879 showWeek: false, // True to show week of the year, false to not show it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6880 calculateWeek: this.iso8601Week, // How to calculate the week of the year,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6881 // takes a Date and returns the number of the week for it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6882 shortYearCutoff: "+10", // Short year values < this are in the current century,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6883 // > this are in the previous century,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6884 // string value starting with "+" for current year + value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6885 minDate: null, // The earliest selectable date, or null for no limit
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6886 maxDate: null, // The latest selectable date, or null for no limit
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6887 duration: "fast", // Duration of display/closure
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6888 beforeShowDay: null, // Function that takes a date and returns an array with
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6889 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6890 // [2] = cell title (optional), e.g. $.datepicker.noWeekends
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6891 beforeShow: null, // Function that takes an input field and
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6892 // returns a set of custom settings for the date picker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6893 onSelect: null, // Define a callback function when a date is selected
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6894 onChangeMonthYear: null, // Define a callback function when the month or year is changed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6895 onClose: null, // Define a callback function when the datepicker is closed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6896 numberOfMonths: 1, // Number of months to show at a time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6897 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6898 stepMonths: 1, // Number of months to step back/forward
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6899 stepBigMonths: 12, // Number of months to step back/forward for the big links
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6900 altField: "", // Selector for an alternate field to store selected dates into
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6901 altFormat: "", // The date format to use for the alternate field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6902 constrainInput: true, // The input is constrained by the current date format
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6903 showButtonPanel: false, // True to show button panel, false to not show it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6904 autoSize: false, // True to size the input for the date format, false to leave as is
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6905 disabled: false // The initial disabled state
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6906 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6907 $.extend(this._defaults, this.regional[""]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6908 this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6909 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6910
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6911 $.extend(Datepicker.prototype, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6912 /* Class name added to elements to indicate already configured with a date picker. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6913 markerClassName: "hasDatepicker",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6914
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6915 //Keep track of the maximum number of rows displayed (see #7043)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6916 maxRows: 4,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6917
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6918 // TODO rename to "widget" when switching to widget factory
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6919 _widgetDatepicker: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6920 return this.dpDiv;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6921 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6922
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6923 /* Override the default settings for all instances of the date picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6924 * @param settings object - the new settings to use as defaults (anonymous object)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6925 * @return the manager object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6926 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6927 setDefaults: function(settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6928 extendRemove(this._defaults, settings || {});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6929 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6930 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6931
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6932 /* Attach the date picker to a jQuery selection.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6933 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6934 * @param settings object - the new settings to use for this date picker instance (anonymous)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6935 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6936 _attachDatepicker: function(target, settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6937 var nodeName, inline, inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6938 nodeName = target.nodeName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6939 inline = (nodeName === "div" || nodeName === "span");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6940 if (!target.id) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6941 this.uuid += 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6942 target.id = "dp" + this.uuid;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6943 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6944 inst = this._newInst($(target), inline);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6945 inst.settings = $.extend({}, settings || {});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6946 if (nodeName === "input") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6947 this._connectDatepicker(target, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6948 } else if (inline) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6949 this._inlineDatepicker(target, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6950 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6951 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6953 /* Create a new instance object. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6954 _newInst: function(target, inline) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6955 var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6956 return {id: id, input: target, // associated target
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6957 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6958 drawMonth: 0, drawYear: 0, // month being drawn
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6959 inline: inline, // is datepicker inline or not
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6960 dpDiv: (!inline ? this.dpDiv : // presentation div
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6961 bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6962 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6963
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6964 /* Attach the date picker to an input field. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6965 _connectDatepicker: function(target, inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6966 var input = $(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6967 inst.append = $([]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6968 inst.trigger = $([]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6969 if (input.hasClass(this.markerClassName)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6970 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6971 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6972 this._attachments(input, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6973 input.addClass(this.markerClassName).keydown(this._doKeyDown).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6974 keypress(this._doKeyPress).keyup(this._doKeyUp);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6975 this._autoSize(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6976 $.data(target, PROP_NAME, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6977 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6978 if( inst.settings.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6979 this._disableDatepicker( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6980 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6981 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6982
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6983 /* Make attachments based on settings. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6984 _attachments: function(input, inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6985 var showOn, buttonText, buttonImage,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6986 appendText = this._get(inst, "appendText"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6987 isRTL = this._get(inst, "isRTL");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6988
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6989 if (inst.append) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6990 inst.append.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6991 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6992 if (appendText) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6993 inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6994 input[isRTL ? "before" : "after"](inst.append);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6995 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6996
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6997 input.unbind("focus", this._showDatepicker);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6998
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6999 if (inst.trigger) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7000 inst.trigger.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7001 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7003 showOn = this._get(inst, "showOn");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7004 if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7005 input.focus(this._showDatepicker);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7006 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7007 if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7008 buttonText = this._get(inst, "buttonText");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7009 buttonImage = this._get(inst, "buttonImage");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7010 inst.trigger = $(this._get(inst, "buttonImageOnly") ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7011 $("<img/>").addClass(this._triggerClass).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7012 attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7013 $("<button type='button'></button>").addClass(this._triggerClass).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7014 html(!buttonImage ? buttonText : $("<img/>").attr(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7015 { src:buttonImage, alt:buttonText, title:buttonText })));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7016 input[isRTL ? "before" : "after"](inst.trigger);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7017 inst.trigger.click(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7018 if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7019 $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7020 } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7021 $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7022 $.datepicker._showDatepicker(input[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7023 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7024 $.datepicker._showDatepicker(input[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7025 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7026 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7027 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7028 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7029 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7030
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7031 /* Apply the maximum length for the date format. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7032 _autoSize: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7033 if (this._get(inst, "autoSize") && !inst.inline) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7034 var findMax, max, maxI, i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7035 date = new Date(2009, 12 - 1, 20), // Ensure double digits
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7036 dateFormat = this._get(inst, "dateFormat");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7037
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7038 if (dateFormat.match(/[DM]/)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7039 findMax = function(names) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7040 max = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7041 maxI = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7042 for (i = 0; i < names.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7043 if (names[i].length > max) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7044 max = names[i].length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7045 maxI = i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7046 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7047 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7048 return maxI;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7049 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7050 date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7051 "monthNames" : "monthNamesShort"))));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7052 date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7053 "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7054 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7055 inst.input.attr("size", this._formatDate(inst, date).length);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7056 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7057 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7058
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7059 /* Attach an inline date picker to a div. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7060 _inlineDatepicker: function(target, inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7061 var divSpan = $(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7062 if (divSpan.hasClass(this.markerClassName)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7063 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7064 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7065 divSpan.addClass(this.markerClassName).append(inst.dpDiv);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7066 $.data(target, PROP_NAME, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7067 this._setDate(inst, this._getDefaultDate(inst), true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7068 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7069 this._updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7070 //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7071 if( inst.settings.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7072 this._disableDatepicker( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7073 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7074 // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7075 // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7076 inst.dpDiv.css( "display", "block" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7077 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7078
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7079 /* Pop-up the date picker in a "dialog" box.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7080 * @param input element - ignored
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7081 * @param date string or Date - the initial date to display
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7082 * @param onSelect function - the function to call when a date is selected
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7083 * @param settings object - update the dialog date picker instance's settings (anonymous object)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7084 * @param pos int[2] - coordinates for the dialog's position within the screen or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7085 * event - with x/y coordinates or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7086 * leave empty for default (screen centre)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7087 * @return the manager object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7088 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7089 _dialogDatepicker: function(input, date, onSelect, settings, pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7090 var id, browserWidth, browserHeight, scrollX, scrollY,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7091 inst = this._dialogInst; // internal instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7092
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7093 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7094 this.uuid += 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7095 id = "dp" + this.uuid;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7096 this._dialogInput = $("<input type='text' id='" + id +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7097 "' style='position: absolute; top: -100px; width: 0px;'/>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7098 this._dialogInput.keydown(this._doKeyDown);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7099 $("body").append(this._dialogInput);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7100 inst = this._dialogInst = this._newInst(this._dialogInput, false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7101 inst.settings = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7102 $.data(this._dialogInput[0], PROP_NAME, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7103 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7104 extendRemove(inst.settings, settings || {});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7105 date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7106 this._dialogInput.val(date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7107
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7108 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7109 if (!this._pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7110 browserWidth = document.documentElement.clientWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7111 browserHeight = document.documentElement.clientHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7112 scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7113 scrollY = document.documentElement.scrollTop || document.body.scrollTop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7114 this._pos = // should use actual width/height below
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7115 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7116 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7117
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7118 // move input on screen for focus, but hidden behind dialog
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7119 this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7120 inst.settings.onSelect = onSelect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7121 this._inDialog = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7122 this.dpDiv.addClass(this._dialogClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7123 this._showDatepicker(this._dialogInput[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7124 if ($.blockUI) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7125 $.blockUI(this.dpDiv);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7126 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7127 $.data(this._dialogInput[0], PROP_NAME, inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7128 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7129 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7130
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7131 /* Detach a datepicker from its control.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7132 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7133 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7134 _destroyDatepicker: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7135 var nodeName,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7136 $target = $(target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7137 inst = $.data(target, PROP_NAME);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7138
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7139 if (!$target.hasClass(this.markerClassName)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7140 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7141 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7142
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7143 nodeName = target.nodeName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7144 $.removeData(target, PROP_NAME);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7145 if (nodeName === "input") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7146 inst.append.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7147 inst.trigger.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7148 $target.removeClass(this.markerClassName).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7149 unbind("focus", this._showDatepicker).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7150 unbind("keydown", this._doKeyDown).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7151 unbind("keypress", this._doKeyPress).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7152 unbind("keyup", this._doKeyUp);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7153 } else if (nodeName === "div" || nodeName === "span") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7154 $target.removeClass(this.markerClassName).empty();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7155 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7156 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7157
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7158 /* Enable the date picker to a jQuery selection.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7159 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7160 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7161 _enableDatepicker: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7162 var nodeName, inline,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7163 $target = $(target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7164 inst = $.data(target, PROP_NAME);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7166 if (!$target.hasClass(this.markerClassName)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7167 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7168 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7169
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7170 nodeName = target.nodeName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7171 if (nodeName === "input") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7172 target.disabled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7173 inst.trigger.filter("button").
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7174 each(function() { this.disabled = false; }).end().
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7175 filter("img").css({opacity: "1.0", cursor: ""});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7176 } else if (nodeName === "div" || nodeName === "span") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7177 inline = $target.children("." + this._inlineClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7178 inline.children().removeClass("ui-state-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7179 inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7180 prop("disabled", false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7181 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7182 this._disabledInputs = $.map(this._disabledInputs,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7183 function(value) { return (value === target ? null : value); }); // delete entry
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7184 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7185
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7186 /* Disable the date picker to a jQuery selection.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7187 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7188 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7189 _disableDatepicker: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7190 var nodeName, inline,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7191 $target = $(target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7192 inst = $.data(target, PROP_NAME);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7193
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7194 if (!$target.hasClass(this.markerClassName)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7195 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7196 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7197
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7198 nodeName = target.nodeName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7199 if (nodeName === "input") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7200 target.disabled = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7201 inst.trigger.filter("button").
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7202 each(function() { this.disabled = true; }).end().
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7203 filter("img").css({opacity: "0.5", cursor: "default"});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7204 } else if (nodeName === "div" || nodeName === "span") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7205 inline = $target.children("." + this._inlineClass);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7206 inline.children().addClass("ui-state-disabled");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7207 inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7208 prop("disabled", true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7209 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7210 this._disabledInputs = $.map(this._disabledInputs,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7211 function(value) { return (value === target ? null : value); }); // delete entry
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7212 this._disabledInputs[this._disabledInputs.length] = target;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7213 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7214
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7215 /* Is the first field in a jQuery collection disabled as a datepicker?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7216 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7217 * @return boolean - true if disabled, false if enabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7218 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7219 _isDisabledDatepicker: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7220 if (!target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7221 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7222 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7223 for (var i = 0; i < this._disabledInputs.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7224 if (this._disabledInputs[i] === target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7225 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7226 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7227 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7228 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7229 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7230
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7231 /* Retrieve the instance data for the target control.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7232 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7233 * @return object - the associated instance data
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7234 * @throws error if a jQuery problem getting data
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7235 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7236 _getInst: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7237 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7238 return $.data(target, PROP_NAME);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7239 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7240 catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7241 throw "Missing instance data for this datepicker";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7242 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7243 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7245 /* Update or retrieve the settings for a date picker attached to an input field or division.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7246 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7247 * @param name object - the new settings to update or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7248 * string - the name of the setting to change or retrieve,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7249 * when retrieving also "all" for all instance settings or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7250 * "defaults" for all global defaults
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7251 * @param value any - the new value for the setting
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7252 * (omit if above is an object or to retrieve a value)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7253 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7254 _optionDatepicker: function(target, name, value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7255 var settings, date, minDate, maxDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7256 inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7257
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7258 if (arguments.length === 2 && typeof name === "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7259 return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7260 (inst ? (name === "all" ? $.extend({}, inst.settings) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7261 this._get(inst, name)) : null));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7262 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7263
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7264 settings = name || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7265 if (typeof name === "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7266 settings = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7267 settings[name] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7268 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7269
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7270 if (inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7271 if (this._curInst === inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7272 this._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7273 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7274
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7275 date = this._getDateDatepicker(target, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7276 minDate = this._getMinMaxDate(inst, "min");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7277 maxDate = this._getMinMaxDate(inst, "max");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7278 extendRemove(inst.settings, settings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7279 // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7280 if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7281 inst.settings.minDate = this._formatDate(inst, minDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7282 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7283 if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7284 inst.settings.maxDate = this._formatDate(inst, maxDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7285 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7286 if ( "disabled" in settings ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7287 if ( settings.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7288 this._disableDatepicker(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7289 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7290 this._enableDatepicker(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7291 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7292 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7293 this._attachments($(target), inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7294 this._autoSize(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7295 this._setDate(inst, date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7296 this._updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7297 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7298 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7299 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7300
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7301 // change method deprecated
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7302 _changeDatepicker: function(target, name, value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7303 this._optionDatepicker(target, name, value);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7304 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7305
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7306 /* Redraw the date picker attached to an input field or division.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7307 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7308 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7309 _refreshDatepicker: function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7310 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7311 if (inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7312 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7313 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7314 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7315
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7316 /* Set the dates for a jQuery selection.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7317 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7318 * @param date Date - the new date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7319 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7320 _setDateDatepicker: function(target, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7321 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7322 if (inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7323 this._setDate(inst, date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7324 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7325 this._updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7326 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7327 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7328
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7329 /* Get the date(s) for the first entry in a jQuery selection.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7330 * @param target element - the target input field or division or span
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7331 * @param noDefault boolean - true if no default date is to be used
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7332 * @return Date - the current date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7333 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7334 _getDateDatepicker: function(target, noDefault) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7335 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7336 if (inst && !inst.inline) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7337 this._setDateFromField(inst, noDefault);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7338 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7339 return (inst ? this._getDate(inst) : null);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7340 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7341
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7342 /* Handle keystrokes. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7343 _doKeyDown: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7344 var onSelect, dateStr, sel,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7345 inst = $.datepicker._getInst(event.target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7346 handled = true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7347 isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7348
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7349 inst._keyEvent = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7350 if ($.datepicker._datepickerShowing) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7351 switch (event.keyCode) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7352 case 9: $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7353 handled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7354 break; // hide on tab out
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7355 case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7356 $.datepicker._currentClass + ")", inst.dpDiv);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7357 if (sel[0]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7358 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7359 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7360
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7361 onSelect = $.datepicker._get(inst, "onSelect");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7362 if (onSelect) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7363 dateStr = $.datepicker._formatDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7364
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7365 // trigger custom callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7366 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7367 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7368 $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7369 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7370
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7371 return false; // don't submit the form
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7372 case 27: $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7373 break; // hide on escape
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7374 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7375 -$.datepicker._get(inst, "stepBigMonths") :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7376 -$.datepicker._get(inst, "stepMonths")), "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7377 break; // previous month/year on page up/+ ctrl
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7378 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7379 +$.datepicker._get(inst, "stepBigMonths") :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7380 +$.datepicker._get(inst, "stepMonths")), "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7381 break; // next month/year on page down/+ ctrl
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7382 case 35: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7383 $.datepicker._clearDate(event.target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7384 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7385 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7386 break; // clear on ctrl or command +end
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7387 case 36: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7388 $.datepicker._gotoToday(event.target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7389 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7390 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7391 break; // current on ctrl or command +home
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7392 case 37: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7393 $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7394 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7395 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7396 // -1 day on ctrl or command +left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7397 if (event.originalEvent.altKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7398 $.datepicker._adjustDate(event.target, (event.ctrlKey ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7399 -$.datepicker._get(inst, "stepBigMonths") :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7400 -$.datepicker._get(inst, "stepMonths")), "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7401 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7402 // next month/year on alt +left on Mac
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7403 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7404 case 38: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7405 $.datepicker._adjustDate(event.target, -7, "D");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7406 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7407 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7408 break; // -1 week on ctrl or command +up
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7409 case 39: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7410 $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7411 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7412 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7413 // +1 day on ctrl or command +right
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7414 if (event.originalEvent.altKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7415 $.datepicker._adjustDate(event.target, (event.ctrlKey ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7416 +$.datepicker._get(inst, "stepBigMonths") :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7417 +$.datepicker._get(inst, "stepMonths")), "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7418 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7419 // next month/year on alt +right
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7420 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7421 case 40: if (event.ctrlKey || event.metaKey) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7422 $.datepicker._adjustDate(event.target, +7, "D");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7423 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7424 handled = event.ctrlKey || event.metaKey;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7425 break; // +1 week on ctrl or command +down
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7426 default: handled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7427 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7428 } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7429 $.datepicker._showDatepicker(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7430 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7431 handled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7432 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7433
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7434 if (handled) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7435 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7436 event.stopPropagation();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7437 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7438 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7439
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7440 /* Filter entered characters - based on date format. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7441 _doKeyPress: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7442 var chars, chr,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7443 inst = $.datepicker._getInst(event.target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7444
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7445 if ($.datepicker._get(inst, "constrainInput")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7446 chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7447 chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7448 return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7449 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7450 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7451
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7452 /* Synchronise manual entry and field/alternate field. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7453 _doKeyUp: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7454 var date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7455 inst = $.datepicker._getInst(event.target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7456
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7457 if (inst.input.val() !== inst.lastVal) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7458 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7459 date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7460 (inst.input ? inst.input.val() : null),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7461 $.datepicker._getFormatConfig(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7462
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7463 if (date) { // only if valid
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7464 $.datepicker._setDateFromField(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7465 $.datepicker._updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7466 $.datepicker._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7467 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7468 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7469 catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7470 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7471 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7472 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7473 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7474
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7475 /* Pop-up the date picker for a given input field.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7476 * If false returned from beforeShow event handler do not show.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7477 * @param input element - the input field attached to the date picker or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7478 * event - if triggered by focus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7479 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7480 _showDatepicker: function(input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7481 input = input.target || input;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7482 if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7483 input = $("input", input.parentNode)[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7484 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7485
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7486 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7487 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7489
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7490 var inst, beforeShow, beforeShowSettings, isFixed,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7491 offset, showAnim, duration;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7492
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7493 inst = $.datepicker._getInst(input);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7494 if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7495 $.datepicker._curInst.dpDiv.stop(true, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7496 if ( inst && $.datepicker._datepickerShowing ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7497 $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7498 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7499 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7500
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7501 beforeShow = $.datepicker._get(inst, "beforeShow");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7502 beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7503 if(beforeShowSettings === false){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7504 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7505 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7506 extendRemove(inst.settings, beforeShowSettings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7507
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7508 inst.lastVal = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7509 $.datepicker._lastInput = input;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7510 $.datepicker._setDateFromField(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7511
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7512 if ($.datepicker._inDialog) { // hide cursor
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7513 input.value = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7514 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7515 if (!$.datepicker._pos) { // position below input
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7516 $.datepicker._pos = $.datepicker._findPos(input);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7517 $.datepicker._pos[1] += input.offsetHeight; // add the height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7518 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7519
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7520 isFixed = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7521 $(input).parents().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7522 isFixed |= $(this).css("position") === "fixed";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7523 return !isFixed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7524 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7525
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7526 offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7527 $.datepicker._pos = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7528 //to avoid flashes on Firefox
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7529 inst.dpDiv.empty();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7530 // determine sizing offscreen
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7531 inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7532 $.datepicker._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7533 // fix width for dynamic number of date pickers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7534 // and adjust position before showing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7535 offset = $.datepicker._checkOffset(inst, offset, isFixed);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7536 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7537 "static" : (isFixed ? "fixed" : "absolute")), display: "none",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7538 left: offset.left + "px", top: offset.top + "px"});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7539
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7540 if (!inst.inline) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7541 showAnim = $.datepicker._get(inst, "showAnim");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7542 duration = $.datepicker._get(inst, "duration");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7543 inst.dpDiv.zIndex($(input).zIndex()+1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7544 $.datepicker._datepickerShowing = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7545
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7546 if ( $.effects && $.effects.effect[ showAnim ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7547 inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7548 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7549 inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7550 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7551
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7552 if ( $.datepicker._shouldFocusInput( inst ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7553 inst.input.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7554 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7555
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7556 $.datepicker._curInst = inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7557 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7558 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7560 /* Generate the date picker content. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7561 _updateDatepicker: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7562 this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7563 instActive = inst; // for delegate hover events
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7564 inst.dpDiv.empty().append(this._generateHTML(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7565 this._attachHandlers(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7566 inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7567
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7568 var origyearshtml,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7569 numMonths = this._getNumberOfMonths(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7570 cols = numMonths[1],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7571 width = 17;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7572
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7573 inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7574 if (cols > 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7575 inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7576 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7577 inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7578 "Class"]("ui-datepicker-multi");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7579 inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7580 "Class"]("ui-datepicker-rtl");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7581
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7582 if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7583 inst.input.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7584 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7585
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7586 // deffered render of the years select (to avoid flashes on Firefox)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7587 if( inst.yearshtml ){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7588 origyearshtml = inst.yearshtml;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7589 setTimeout(function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7590 //assure that inst.yearshtml didn't change.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7591 if( origyearshtml === inst.yearshtml && inst.yearshtml ){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7592 inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7593 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7594 origyearshtml = inst.yearshtml = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7595 }, 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7596 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7597 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7598
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7599 // #6694 - don't focus the input if it's already focused
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7600 // this breaks the change event in IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7601 // Support: IE and jQuery <1.9
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7602 _shouldFocusInput: function( inst ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7603 return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7604 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7605
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7606 /* Check positioning to remain on screen. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7607 _checkOffset: function(inst, offset, isFixed) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7608 var dpWidth = inst.dpDiv.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7609 dpHeight = inst.dpDiv.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7610 inputWidth = inst.input ? inst.input.outerWidth() : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7611 inputHeight = inst.input ? inst.input.outerHeight() : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7612 viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7613 viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7614
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7615 offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7616 offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7617 offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7618
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7619 // now check if datepicker is showing outside window viewport - move to a better place if so.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7620 offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7621 Math.abs(offset.left + dpWidth - viewWidth) : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7622 offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7623 Math.abs(dpHeight + inputHeight) : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7624
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7625 return offset;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7626 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7627
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7628 /* Find an object's position on the screen. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7629 _findPos: function(obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7630 var position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7631 inst = this._getInst(obj),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7632 isRTL = this._get(inst, "isRTL");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7634 while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7635 obj = obj[isRTL ? "previousSibling" : "nextSibling"];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7636 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7638 position = $(obj).offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7639 return [position.left, position.top];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7640 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7641
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7642 /* Hide the date picker from view.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7643 * @param input element - the input field attached to the date picker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7644 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7645 _hideDatepicker: function(input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7646 var showAnim, duration, postProcess, onClose,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7647 inst = this._curInst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7648
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7649 if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7650 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7651 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7652
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7653 if (this._datepickerShowing) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7654 showAnim = this._get(inst, "showAnim");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7655 duration = this._get(inst, "duration");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7656 postProcess = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7657 $.datepicker._tidyDialog(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7658 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7659
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7660 // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7661 if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7662 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7663 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7664 inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7665 (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7666 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7667
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7668 if (!showAnim) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7669 postProcess();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7670 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7671 this._datepickerShowing = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7672
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7673 onClose = this._get(inst, "onClose");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7674 if (onClose) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7675 onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7676 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7677
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7678 this._lastInput = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7679 if (this._inDialog) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7680 this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7681 if ($.blockUI) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7682 $.unblockUI();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7683 $("body").append(this.dpDiv);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7684 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7685 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7686 this._inDialog = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7687 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7688 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7689
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7690 /* Tidy up after a dialog display. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7691 _tidyDialog: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7692 inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7693 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7694
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7695 /* Close date picker if clicked elsewhere. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7696 _checkExternalClick: function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7697 if (!$.datepicker._curInst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7698 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7699 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7700
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7701 var $target = $(event.target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7702 inst = $.datepicker._getInst($target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7703
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7704 if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7705 $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7706 !$target.hasClass($.datepicker.markerClassName) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7707 !$target.closest("." + $.datepicker._triggerClass).length &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7708 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7709 ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7710 $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7711 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7712 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7713
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7714 /* Adjust one of the date sub-fields. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7715 _adjustDate: function(id, offset, period) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7716 var target = $(id),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7717 inst = this._getInst(target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7718
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7719 if (this._isDisabledDatepicker(target[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7720 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7721 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7722 this._adjustInstDate(inst, offset +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7723 (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7724 period);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7725 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7726 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7727
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7728 /* Action for current link. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7729 _gotoToday: function(id) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7730 var date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7731 target = $(id),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7732 inst = this._getInst(target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7733
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7734 if (this._get(inst, "gotoCurrent") && inst.currentDay) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7735 inst.selectedDay = inst.currentDay;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7736 inst.drawMonth = inst.selectedMonth = inst.currentMonth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7737 inst.drawYear = inst.selectedYear = inst.currentYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7738 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7739 date = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7740 inst.selectedDay = date.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7741 inst.drawMonth = inst.selectedMonth = date.getMonth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7742 inst.drawYear = inst.selectedYear = date.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7743 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7744 this._notifyChange(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7745 this._adjustDate(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7746 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7747
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7748 /* Action for selecting a new month/year. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7749 _selectMonthYear: function(id, select, period) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7750 var target = $(id),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7751 inst = this._getInst(target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7752
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7753 inst["selected" + (period === "M" ? "Month" : "Year")] =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7754 inst["draw" + (period === "M" ? "Month" : "Year")] =
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7755 parseInt(select.options[select.selectedIndex].value,10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7756
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7757 this._notifyChange(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7758 this._adjustDate(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7759 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7760
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7761 /* Action for selecting a day. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7762 _selectDay: function(id, month, year, td) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7763 var inst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7764 target = $(id);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7765
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7766 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7767 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7768 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7769
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7770 inst = this._getInst(target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7771 inst.selectedDay = inst.currentDay = $("a", td).html();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7772 inst.selectedMonth = inst.currentMonth = month;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7773 inst.selectedYear = inst.currentYear = year;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7774 this._selectDate(id, this._formatDate(inst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7775 inst.currentDay, inst.currentMonth, inst.currentYear));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7776 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7778 /* Erase the input field and hide the date picker. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7779 _clearDate: function(id) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7780 var target = $(id);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7781 this._selectDate(target, "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7782 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7783
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7784 /* Update the input field with the selected date. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7785 _selectDate: function(id, dateStr) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7786 var onSelect,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7787 target = $(id),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7788 inst = this._getInst(target[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7789
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7790 dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7791 if (inst.input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7792 inst.input.val(dateStr);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7793 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7794 this._updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7795
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7796 onSelect = this._get(inst, "onSelect");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7797 if (onSelect) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7798 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7799 } else if (inst.input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7800 inst.input.trigger("change"); // fire the change event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7801 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7802
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7803 if (inst.inline){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7804 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7805 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7806 this._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7807 this._lastInput = inst.input[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7808 if (typeof(inst.input[0]) !== "object") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7809 inst.input.focus(); // restore focus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7810 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7811 this._lastInput = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7812 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7813 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7814
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7815 /* Update any alternate field to synchronise with the main field. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7816 _updateAlternate: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7817 var altFormat, date, dateStr,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7818 altField = this._get(inst, "altField");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7819
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7820 if (altField) { // update alternate field too
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7821 altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7822 date = this._getDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7823 dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7824 $(altField).each(function() { $(this).val(dateStr); });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7825 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7826 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7827
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7828 /* Set as beforeShowDay function to prevent selection of weekends.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7829 * @param date Date - the date to customise
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7830 * @return [boolean, string] - is this date selectable?, what is its CSS class?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7831 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7832 noWeekends: function(date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7833 var day = date.getDay();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7834 return [(day > 0 && day < 6), ""];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7835 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7836
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7837 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7838 * @param date Date - the date to get the week for
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7839 * @return number - the number of the week within the year that contains this date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7840 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7841 iso8601Week: function(date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7842 var time,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7843 checkDate = new Date(date.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7844
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7845 // Find Thursday of this week starting on Monday
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7846 checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7847
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7848 time = checkDate.getTime();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7849 checkDate.setMonth(0); // Compare with Jan 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7850 checkDate.setDate(1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7851 return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7852 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7853
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7854 /* Parse a string value into a date object.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7855 * See formatDate below for the possible formats.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7856 *
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7857 * @param format string - the expected format of the date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7858 * @param value string - the date in the above format
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7859 * @param settings Object - attributes include:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7860 * shortYearCutoff number - the cutoff year for determining the century (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7861 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7862 * dayNames string[7] - names of the days from Sunday (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7863 * monthNamesShort string[12] - abbreviated names of the months (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7864 * monthNames string[12] - names of the months (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7865 * @return Date - the extracted date value or null if value is blank
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7866 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7867 parseDate: function (format, value, settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7868 if (format == null || value == null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7869 throw "Invalid arguments";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7870 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7871
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7872 value = (typeof value === "object" ? value.toString() : value + "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7873 if (value === "") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7874 return null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7875 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7877 var iFormat, dim, extra,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7878 iValue = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7879 shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7880 shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7881 new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7882 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7883 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7884 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7885 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7886 year = -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7887 month = -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7888 day = -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7889 doy = -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7890 literal = false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7891 date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7892 // Check whether a format character is doubled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7893 lookAhead = function(match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7894 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7895 if (matches) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7896 iFormat++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7897 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7898 return matches;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7899 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7900 // Extract a number from the string value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7901 getNumber = function(match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7902 var isDoubled = lookAhead(match),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7903 size = (match === "@" ? 14 : (match === "!" ? 20 :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7904 (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7905 digits = new RegExp("^\\d{1," + size + "}"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7906 num = value.substring(iValue).match(digits);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7907 if (!num) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7908 throw "Missing number at position " + iValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7909 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7910 iValue += num[0].length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7911 return parseInt(num[0], 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7912 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7913 // Extract a name from the string value and convert to an index
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7914 getName = function(match, shortNames, longNames) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7915 var index = -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7916 names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7917 return [ [k, v] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7918 }).sort(function (a, b) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7919 return -(a[1].length - b[1].length);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7920 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7921
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7922 $.each(names, function (i, pair) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7923 var name = pair[1];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7924 if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7925 index = pair[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7926 iValue += name.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7927 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7928 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7929 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7930 if (index !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7931 return index + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7932 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7933 throw "Unknown name at position " + iValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7934 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7935 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7936 // Confirm that a literal character matches the string value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7937 checkLiteral = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7938 if (value.charAt(iValue) !== format.charAt(iFormat)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7939 throw "Unexpected literal at position " + iValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7940 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7941 iValue++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7942 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7943
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7944 for (iFormat = 0; iFormat < format.length; iFormat++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7945 if (literal) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7946 if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7947 literal = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7948 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7949 checkLiteral();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7950 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7951 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7952 switch (format.charAt(iFormat)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7953 case "d":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7954 day = getNumber("d");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7955 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7956 case "D":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7957 getName("D", dayNamesShort, dayNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7958 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7959 case "o":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7960 doy = getNumber("o");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7961 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7962 case "m":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7963 month = getNumber("m");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7964 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7965 case "M":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7966 month = getName("M", monthNamesShort, monthNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7967 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7968 case "y":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7969 year = getNumber("y");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7970 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7971 case "@":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7972 date = new Date(getNumber("@"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7973 year = date.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7974 month = date.getMonth() + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7975 day = date.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7976 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7977 case "!":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7978 date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7979 year = date.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7980 month = date.getMonth() + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7981 day = date.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7982 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7983 case "'":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7984 if (lookAhead("'")){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7985 checkLiteral();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7986 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7987 literal = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7988 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7989 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7990 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7991 checkLiteral();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7992 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7993 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7994 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7995
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7996 if (iValue < value.length){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7997 extra = value.substr(iValue);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7998 if (!/^\s+/.test(extra)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7999 throw "Extra/unparsed characters found in date: " + extra;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8000 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8001 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8003 if (year === -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8004 year = new Date().getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8005 } else if (year < 100) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8006 year += new Date().getFullYear() - new Date().getFullYear() % 100 +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8007 (year <= shortYearCutoff ? 0 : -100);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8008 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8009
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8010 if (doy > -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8011 month = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8012 day = doy;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8013 do {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8014 dim = this._getDaysInMonth(year, month - 1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8015 if (day <= dim) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8016 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8017 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8018 month++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8019 day -= dim;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8020 } while (true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8021 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8022
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8023 date = this._daylightSavingAdjust(new Date(year, month - 1, day));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8024 if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8025 throw "Invalid date"; // E.g. 31/02/00
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8026 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8027 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8028 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8029
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8030 /* Standard date formats. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8031 ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8032 COOKIE: "D, dd M yy",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8033 ISO_8601: "yy-mm-dd",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8034 RFC_822: "D, d M y",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8035 RFC_850: "DD, dd-M-y",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8036 RFC_1036: "D, d M y",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8037 RFC_1123: "D, d M yy",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8038 RFC_2822: "D, d M yy",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8039 RSS: "D, d M y", // RFC 822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8040 TICKS: "!",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8041 TIMESTAMP: "@",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8042 W3C: "yy-mm-dd", // ISO 8601
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8043
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8044 _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8045 Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8046
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8047 /* Format a date object into a string value.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8048 * The format can be combinations of the following:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8049 * d - day of month (no leading zero)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8050 * dd - day of month (two digit)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8051 * o - day of year (no leading zeros)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8052 * oo - day of year (three digit)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8053 * D - day name short
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8054 * DD - day name long
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8055 * m - month of year (no leading zero)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8056 * mm - month of year (two digit)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8057 * M - month name short
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8058 * MM - month name long
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8059 * y - year (two digit)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8060 * yy - year (four digit)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8061 * @ - Unix timestamp (ms since 01/01/1970)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8062 * ! - Windows ticks (100ns since 01/01/0001)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8063 * "..." - literal text
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8064 * '' - single quote
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8065 *
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8066 * @param format string - the desired format of the date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8067 * @param date Date - the date value to format
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8068 * @param settings Object - attributes include:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8069 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8070 * dayNames string[7] - names of the days from Sunday (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8071 * monthNamesShort string[12] - abbreviated names of the months (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8072 * monthNames string[12] - names of the months (optional)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8073 * @return string - the date in the above format
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8074 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8075 formatDate: function (format, date, settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8076 if (!date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8077 return "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8078 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8079
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8080 var iFormat,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8081 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8082 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8083 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8084 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8085 // Check whether a format character is doubled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8086 lookAhead = function(match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8087 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8088 if (matches) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8089 iFormat++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8090 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8091 return matches;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8092 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8093 // Format a number, with leading zero if necessary
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8094 formatNumber = function(match, value, len) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8095 var num = "" + value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8096 if (lookAhead(match)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8097 while (num.length < len) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8098 num = "0" + num;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8099 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8100 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8101 return num;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8102 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8103 // Format a name, short or long as requested
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8104 formatName = function(match, value, shortNames, longNames) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8105 return (lookAhead(match) ? longNames[value] : shortNames[value]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8106 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8107 output = "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8108 literal = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8109
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8110 if (date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8111 for (iFormat = 0; iFormat < format.length; iFormat++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8112 if (literal) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8113 if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8114 literal = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8115 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8116 output += format.charAt(iFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8117 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8118 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8119 switch (format.charAt(iFormat)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8120 case "d":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8121 output += formatNumber("d", date.getDate(), 2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8122 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8123 case "D":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8124 output += formatName("D", date.getDay(), dayNamesShort, dayNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8125 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8126 case "o":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8127 output += formatNumber("o",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8128 Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8129 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8130 case "m":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8131 output += formatNumber("m", date.getMonth() + 1, 2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8132 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8133 case "M":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8134 output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8135 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8136 case "y":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8137 output += (lookAhead("y") ? date.getFullYear() :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8138 (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8139 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8140 case "@":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8141 output += date.getTime();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8142 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8143 case "!":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8144 output += date.getTime() * 10000 + this._ticksTo1970;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8145 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8146 case "'":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8147 if (lookAhead("'")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8148 output += "'";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8149 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8150 literal = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8151 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8152 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8153 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8154 output += format.charAt(iFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8155 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8156 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8157 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8159 return output;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8160 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8161
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8162 /* Extract all possible characters from the date format. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8163 _possibleChars: function (format) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8164 var iFormat,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8165 chars = "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8166 literal = false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8167 // Check whether a format character is doubled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8168 lookAhead = function(match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8169 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8170 if (matches) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8171 iFormat++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8172 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8173 return matches;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8174 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8175
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8176 for (iFormat = 0; iFormat < format.length; iFormat++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8177 if (literal) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8178 if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8179 literal = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8180 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8181 chars += format.charAt(iFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8182 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8183 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8184 switch (format.charAt(iFormat)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8185 case "d": case "m": case "y": case "@":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8186 chars += "0123456789";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8187 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8188 case "D": case "M":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8189 return null; // Accept anything
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8190 case "'":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8191 if (lookAhead("'")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8192 chars += "'";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8193 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8194 literal = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8195 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8196 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8197 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8198 chars += format.charAt(iFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8199 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8200 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8201 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8202 return chars;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8203 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8204
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8205 /* Get a setting value, defaulting if necessary. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8206 _get: function(inst, name) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8207 return inst.settings[name] !== undefined ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8208 inst.settings[name] : this._defaults[name];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8209 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8210
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8211 /* Parse existing date and initialise date picker. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8212 _setDateFromField: function(inst, noDefault) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8213 if (inst.input.val() === inst.lastVal) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8214 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8215 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8216
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8217 var dateFormat = this._get(inst, "dateFormat"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8218 dates = inst.lastVal = inst.input ? inst.input.val() : null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8219 defaultDate = this._getDefaultDate(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8220 date = defaultDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8221 settings = this._getFormatConfig(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8222
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8223 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8224 date = this.parseDate(dateFormat, dates, settings) || defaultDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8225 } catch (event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8226 dates = (noDefault ? "" : dates);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8227 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8228 inst.selectedDay = date.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8229 inst.drawMonth = inst.selectedMonth = date.getMonth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8230 inst.drawYear = inst.selectedYear = date.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8231 inst.currentDay = (dates ? date.getDate() : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8232 inst.currentMonth = (dates ? date.getMonth() : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8233 inst.currentYear = (dates ? date.getFullYear() : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8234 this._adjustInstDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8235 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8236
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8237 /* Retrieve the default date shown on opening. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8238 _getDefaultDate: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8239 return this._restrictMinMax(inst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8240 this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8241 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8242
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8243 /* A date may be specified as an exact value or a relative one. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8244 _determineDate: function(inst, date, defaultDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8245 var offsetNumeric = function(offset) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8246 var date = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8247 date.setDate(date.getDate() + offset);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8248 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8249 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8250 offsetString = function(offset) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8251 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8252 return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8253 offset, $.datepicker._getFormatConfig(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8254 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8255 catch (e) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8256 // Ignore
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8257 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8258
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8259 var date = (offset.toLowerCase().match(/^c/) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8260 $.datepicker._getDate(inst) : null) || new Date(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8261 year = date.getFullYear(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8262 month = date.getMonth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8263 day = date.getDate(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8264 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8265 matches = pattern.exec(offset);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8266
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8267 while (matches) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8268 switch (matches[2] || "d") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8269 case "d" : case "D" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8270 day += parseInt(matches[1],10); break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8271 case "w" : case "W" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8272 day += parseInt(matches[1],10) * 7; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8273 case "m" : case "M" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8274 month += parseInt(matches[1],10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8275 day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8276 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8277 case "y": case "Y" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8278 year += parseInt(matches[1],10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8279 day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8280 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8281 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8282 matches = pattern.exec(offset);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8283 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8284 return new Date(year, month, day);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8285 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8286 newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8287 (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8288
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8289 newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8290 if (newDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8291 newDate.setHours(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8292 newDate.setMinutes(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8293 newDate.setSeconds(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8294 newDate.setMilliseconds(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8295 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8296 return this._daylightSavingAdjust(newDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8297 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8298
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8299 /* Handle switch to/from daylight saving.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8300 * Hours may be non-zero on daylight saving cut-over:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8301 * > 12 when midnight changeover, but then cannot generate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8302 * midnight datetime, so jump to 1AM, otherwise reset.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8303 * @param date (Date) the date to check
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8304 * @return (Date) the corrected date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8305 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8306 _daylightSavingAdjust: function(date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8307 if (!date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8308 return null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8309 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8310 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8311 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8312 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8313
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8314 /* Set the date(s) directly. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8315 _setDate: function(inst, date, noChange) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8316 var clear = !date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8317 origMonth = inst.selectedMonth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8318 origYear = inst.selectedYear,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8319 newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8320
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8321 inst.selectedDay = inst.currentDay = newDate.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8322 inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8323 inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8324 if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8325 this._notifyChange(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8326 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8327 this._adjustInstDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8328 if (inst.input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8329 inst.input.val(clear ? "" : this._formatDate(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8330 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8331 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8332
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8333 /* Retrieve the date(s) directly. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8334 _getDate: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8335 var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8336 this._daylightSavingAdjust(new Date(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8337 inst.currentYear, inst.currentMonth, inst.currentDay)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8338 return startDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8339 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8340
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8341 /* Attach the onxxx handlers. These are declared statically so
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8342 * they work with static code transformers like Caja.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8343 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8344 _attachHandlers: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8345 var stepMonths = this._get(inst, "stepMonths"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8346 id = "#" + inst.id.replace( /\\\\/g, "\\" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8347 inst.dpDiv.find("[data-handler]").map(function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8348 var handler = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8349 prev: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8350 $.datepicker._adjustDate(id, -stepMonths, "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8351 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8352 next: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8353 $.datepicker._adjustDate(id, +stepMonths, "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8354 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8355 hide: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8356 $.datepicker._hideDatepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8357 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8358 today: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8359 $.datepicker._gotoToday(id);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8360 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8361 selectDay: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8362 $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8363 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8364 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8365 selectMonth: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8366 $.datepicker._selectMonthYear(id, this, "M");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8367 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8368 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8369 selectYear: function () {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8370 $.datepicker._selectMonthYear(id, this, "Y");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8371 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8372 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8373 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8374 $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8375 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8376 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8377
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8378 /* Generate the HTML for the current state of the date picker. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8379 _generateHTML: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8380 var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8381 controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8382 monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8383 selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8384 cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8385 printDate, dRow, tbody, daySettings, otherMonth, unselectable,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8386 tempDate = new Date(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8387 today = this._daylightSavingAdjust(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8388 new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8389 isRTL = this._get(inst, "isRTL"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8390 showButtonPanel = this._get(inst, "showButtonPanel"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8391 hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8392 navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8393 numMonths = this._getNumberOfMonths(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8394 showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8395 stepMonths = this._get(inst, "stepMonths"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8396 isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8397 currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8398 new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8399 minDate = this._getMinMaxDate(inst, "min"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8400 maxDate = this._getMinMaxDate(inst, "max"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8401 drawMonth = inst.drawMonth - showCurrentAtPos,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8402 drawYear = inst.drawYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8403
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8404 if (drawMonth < 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8405 drawMonth += 12;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8406 drawYear--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8407 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8408 if (maxDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8409 maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8410 maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8411 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8412 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8413 drawMonth--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8414 if (drawMonth < 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8415 drawMonth = 11;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8416 drawYear--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8417 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8418 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8419 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8420 inst.drawMonth = drawMonth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8421 inst.drawYear = drawYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8422
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8423 prevText = this._get(inst, "prevText");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8424 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8425 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8426 this._getFormatConfig(inst)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8427
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8428 prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8429 "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8430 " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8431 (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8432
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8433 nextText = this._get(inst, "nextText");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8434 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8435 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8436 this._getFormatConfig(inst)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8437
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8438 next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8439 "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8440 " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8441 (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8442
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8443 currentText = this._get(inst, "currentText");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8444 gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8445 currentText = (!navigationAsDateFormat ? currentText :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8446 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8447
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8448 controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8449 this._get(inst, "closeText") + "</button>" : "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8450
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8451 buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8452 (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8453 ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8454
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8455 firstDay = parseInt(this._get(inst, "firstDay"),10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8456 firstDay = (isNaN(firstDay) ? 0 : firstDay);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8457
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8458 showWeek = this._get(inst, "showWeek");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8459 dayNames = this._get(inst, "dayNames");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8460 dayNamesMin = this._get(inst, "dayNamesMin");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8461 monthNames = this._get(inst, "monthNames");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8462 monthNamesShort = this._get(inst, "monthNamesShort");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8463 beforeShowDay = this._get(inst, "beforeShowDay");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8464 showOtherMonths = this._get(inst, "showOtherMonths");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8465 selectOtherMonths = this._get(inst, "selectOtherMonths");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8466 defaultDate = this._getDefaultDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8467 html = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8468 dow;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8469 for (row = 0; row < numMonths[0]; row++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8470 group = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8471 this.maxRows = 4;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8472 for (col = 0; col < numMonths[1]; col++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8473 selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8474 cornerClass = " ui-corner-all";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8475 calender = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8476 if (isMultiMonth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8477 calender += "<div class='ui-datepicker-group";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8478 if (numMonths[1] > 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8479 switch (col) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8480 case 0: calender += " ui-datepicker-group-first";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8481 cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8482 case numMonths[1]-1: calender += " ui-datepicker-group-last";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8483 cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8484 default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8485 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8486 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8487 calender += "'>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8489 calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8490 (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8491 (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8492 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8493 row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8494 "</div><table class='ui-datepicker-calendar'><thead>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8495 "<tr>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8496 thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8497 for (dow = 0; dow < 7; dow++) { // days of the week
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8498 day = (dow + firstDay) % 7;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8499 thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8500 "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8501 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8502 calender += thead + "</tr></thead><tbody>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8503 daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8504 if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8505 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8506 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8507 leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8508 curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8509 numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8510 this.maxRows = numRows;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8511 printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8512 for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8513 calender += "<tr>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8514 tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8515 this._get(inst, "calculateWeek")(printDate) + "</td>");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8516 for (dow = 0; dow < 7; dow++) { // create date picker days
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8517 daySettings = (beforeShowDay ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8518 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8519 otherMonth = (printDate.getMonth() !== drawMonth);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8520 unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8521 (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8522 tbody += "<td class='" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8523 ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8524 (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8525 ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8526 (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8527 // or defaultDate is current printedDate and defaultDate is selectedDate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8528 " " + this._dayOverClass : "") + // highlight selected day
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8529 (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8530 (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8531 (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8532 (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8533 ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8534 (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8535 (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8536 (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8537 (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8538 (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8539 (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8540 "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8541 printDate.setDate(printDate.getDate() + 1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8542 printDate = this._daylightSavingAdjust(printDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8543 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8544 calender += tbody + "</tr>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8545 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8546 drawMonth++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8547 if (drawMonth > 11) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8548 drawMonth = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8549 drawYear++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8550 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8551 calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8552 ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8553 group += calender;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8554 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8555 html += group;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8556 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8557 html += buttonPanel;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8558 inst._keyEvent = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8559 return html;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8560 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8561
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8562 /* Generate the month and year header. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8563 _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8564 secondary, monthNames, monthNamesShort) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8565
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8566 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8567 changeMonth = this._get(inst, "changeMonth"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8568 changeYear = this._get(inst, "changeYear"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8569 showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8570 html = "<div class='ui-datepicker-title'>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8571 monthHtml = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8572
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8573 // month selection
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8574 if (secondary || !changeMonth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8575 monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8576 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8577 inMinYear = (minDate && minDate.getFullYear() === drawYear);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8578 inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8579 monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8580 for ( month = 0; month < 12; month++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8581 if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8582 monthHtml += "<option value='" + month + "'" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8583 (month === drawMonth ? " selected='selected'" : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8584 ">" + monthNamesShort[month] + "</option>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8585 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8586 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8587 monthHtml += "</select>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8588 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8589
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8590 if (!showMonthAfterYear) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8591 html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8592 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8593
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8594 // year selection
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8595 if ( !inst.yearshtml ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8596 inst.yearshtml = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8597 if (secondary || !changeYear) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8598 html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8599 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8600 // determine range of years to display
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8601 years = this._get(inst, "yearRange").split(":");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8602 thisYear = new Date().getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8603 determineYear = function(value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8604 var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8605 (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8606 parseInt(value, 10)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8607 return (isNaN(year) ? thisYear : year);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8608 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8609 year = determineYear(years[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8610 endYear = Math.max(year, determineYear(years[1] || ""));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8611 year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8612 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8613 inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8614 for (; year <= endYear; year++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8615 inst.yearshtml += "<option value='" + year + "'" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8616 (year === drawYear ? " selected='selected'" : "") +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8617 ">" + year + "</option>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8618 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8619 inst.yearshtml += "</select>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8620
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8621 html += inst.yearshtml;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8622 inst.yearshtml = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8623 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8624 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8625
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8626 html += this._get(inst, "yearSuffix");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8627 if (showMonthAfterYear) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8628 html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8629 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8630 html += "</div>"; // Close datepicker_header
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8631 return html;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8632 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8634 /* Adjust one of the date sub-fields. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8635 _adjustInstDate: function(inst, offset, period) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8636 var year = inst.drawYear + (period === "Y" ? offset : 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8637 month = inst.drawMonth + (period === "M" ? offset : 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8638 day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8639 date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8640
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8641 inst.selectedDay = date.getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8642 inst.drawMonth = inst.selectedMonth = date.getMonth();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8643 inst.drawYear = inst.selectedYear = date.getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8644 if (period === "M" || period === "Y") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8645 this._notifyChange(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8646 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8647 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8648
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8649 /* Ensure a date is within any min/max bounds. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8650 _restrictMinMax: function(inst, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8651 var minDate = this._getMinMaxDate(inst, "min"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8652 maxDate = this._getMinMaxDate(inst, "max"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8653 newDate = (minDate && date < minDate ? minDate : date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8654 return (maxDate && newDate > maxDate ? maxDate : newDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8655 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8656
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8657 /* Notify change of month/year. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8658 _notifyChange: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8659 var onChange = this._get(inst, "onChangeMonthYear");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8660 if (onChange) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8661 onChange.apply((inst.input ? inst.input[0] : null),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8662 [inst.selectedYear, inst.selectedMonth + 1, inst]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8663 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8664 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8665
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8666 /* Determine the number of months to show. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8667 _getNumberOfMonths: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8668 var numMonths = this._get(inst, "numberOfMonths");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8669 return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8670 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8671
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8672 /* Determine the current maximum date - ensure no time components are set. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8673 _getMinMaxDate: function(inst, minMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8674 return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8675 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8676
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8677 /* Find the number of days in a given month. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8678 _getDaysInMonth: function(year, month) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8679 return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8680 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8681
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8682 /* Find the day of the week of the first of a month. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8683 _getFirstDayOfMonth: function(year, month) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8684 return new Date(year, month, 1).getDay();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8685 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8686
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8687 /* Determines if we should allow a "next/prev" month display change. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8688 _canAdjustMonth: function(inst, offset, curYear, curMonth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8689 var numMonths = this._getNumberOfMonths(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8690 date = this._daylightSavingAdjust(new Date(curYear,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8691 curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8692
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8693 if (offset < 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8694 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8695 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8696 return this._isInRange(inst, date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8697 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8698
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8699 /* Is the given date in the accepted range? */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8700 _isInRange: function(inst, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8701 var yearSplit, currentYear,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8702 minDate = this._getMinMaxDate(inst, "min"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8703 maxDate = this._getMinMaxDate(inst, "max"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8704 minYear = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8705 maxYear = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8706 years = this._get(inst, "yearRange");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8707 if (years){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8708 yearSplit = years.split(":");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8709 currentYear = new Date().getFullYear();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8710 minYear = parseInt(yearSplit[0], 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8711 maxYear = parseInt(yearSplit[1], 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8712 if ( yearSplit[0].match(/[+\-].*/) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8713 minYear += currentYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8714 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8715 if ( yearSplit[1].match(/[+\-].*/) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8716 maxYear += currentYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8717 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8718 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8719
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8720 return ((!minDate || date.getTime() >= minDate.getTime()) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8721 (!maxDate || date.getTime() <= maxDate.getTime()) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8722 (!minYear || date.getFullYear() >= minYear) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8723 (!maxYear || date.getFullYear() <= maxYear));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8724 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8725
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8726 /* Provide the configuration settings for formatting/parsing. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8727 _getFormatConfig: function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8728 var shortYearCutoff = this._get(inst, "shortYearCutoff");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8729 shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8730 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8731 return {shortYearCutoff: shortYearCutoff,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8732 dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8733 monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8734 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8735
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8736 /* Format the given date for display. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8737 _formatDate: function(inst, day, month, year) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8738 if (!day) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8739 inst.currentDay = inst.selectedDay;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8740 inst.currentMonth = inst.selectedMonth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8741 inst.currentYear = inst.selectedYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8742 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8743 var date = (day ? (typeof day === "object" ? day :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8744 this._daylightSavingAdjust(new Date(year, month, day))) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8745 this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8746 return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8747 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8748 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8749
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8750 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8751 * Bind hover events for datepicker elements.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8752 * Done via delegate so the binding only occurs once in the lifetime of the parent div.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8753 * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8754 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8755 function bindHover(dpDiv) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8756 var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8757 return dpDiv.delegate(selector, "mouseout", function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8758 $(this).removeClass("ui-state-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8759 if (this.className.indexOf("ui-datepicker-prev") !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8760 $(this).removeClass("ui-datepicker-prev-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8761 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8762 if (this.className.indexOf("ui-datepicker-next") !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8763 $(this).removeClass("ui-datepicker-next-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8764 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8765 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8766 .delegate(selector, "mouseover", function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8767 if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8768 $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8769 $(this).addClass("ui-state-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8770 if (this.className.indexOf("ui-datepicker-prev") !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8771 $(this).addClass("ui-datepicker-prev-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8772 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8773 if (this.className.indexOf("ui-datepicker-next") !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8774 $(this).addClass("ui-datepicker-next-hover");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8775 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8776 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8777 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8778 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8779
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8780 /* jQuery extend now ignores nulls! */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8781 function extendRemove(target, props) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8782 $.extend(target, props);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8783 for (var name in props) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8784 if (props[name] == null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8785 target[name] = props[name];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8786 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8787 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8788 return target;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8789 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8790
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8791 /* Invoke the datepicker functionality.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8792 @param options string - a command, optionally followed by additional parameters or
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8793 Object - settings for attaching new datepicker functionality
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8794 @return jQuery object */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8795 $.fn.datepicker = function(options){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8796
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8797 /* Verify an empty collection wasn't passed - Fixes #6976 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8798 if ( !this.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8799 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8800 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8801
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8802 /* Initialise the date picker. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8803 if (!$.datepicker.initialized) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8804 $(document).mousedown($.datepicker._checkExternalClick);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8805 $.datepicker.initialized = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8806 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8807
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8808 /* Append datepicker main container to body if not exist. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8809 if ($("#"+$.datepicker._mainDivId).length === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8810 $("body").append($.datepicker.dpDiv);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8811 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8812
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8813 var otherArgs = Array.prototype.slice.call(arguments, 1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8814 if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8815 return $.datepicker["_" + options + "Datepicker"].
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8816 apply($.datepicker, [this[0]].concat(otherArgs));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8817 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8818 if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8819 return $.datepicker["_" + options + "Datepicker"].
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8820 apply($.datepicker, [this[0]].concat(otherArgs));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8821 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8822 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8823 typeof options === "string" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8824 $.datepicker["_" + options + "Datepicker"].
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8825 apply($.datepicker, [this].concat(otherArgs)) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8826 $.datepicker._attachDatepicker(this, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8827 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8828 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8829
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8830 $.datepicker = new Datepicker(); // singleton instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8831 $.datepicker.initialized = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8832 $.datepicker.uuid = new Date().getTime();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8833 $.datepicker.version = "1.10.3";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8834
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8835 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8836 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8837
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8838 var sizeRelatedOptions = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8839 buttons: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8840 height: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8841 maxHeight: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8842 maxWidth: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8843 minHeight: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8844 minWidth: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8845 width: true
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8846 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8847 resizableRelatedOptions = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8848 maxHeight: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8849 maxWidth: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8850 minHeight: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8851 minWidth: true
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8852 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8853
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8854 $.widget( "ui.dialog", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8855 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8856 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8857 appendTo: "body",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8858 autoOpen: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8859 buttons: [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8860 closeOnEscape: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8861 closeText: "close",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8862 dialogClass: "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8863 draggable: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8864 hide: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8865 height: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8866 maxHeight: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8867 maxWidth: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8868 minHeight: 150,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8869 minWidth: 150,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8870 modal: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8871 position: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8872 my: "center",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8873 at: "center",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8874 of: window,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8875 collision: "fit",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8876 // Ensure the titlebar is always visible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8877 using: function( pos ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8878 var topOffset = $( this ).css( pos ).offset().top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8879 if ( topOffset < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8880 $( this ).css( "top", pos.top - topOffset );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8881 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8882 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8883 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8884 resizable: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8885 show: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8886 title: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8887 width: 300,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8888
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8889 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8890 beforeClose: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8891 close: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8892 drag: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8893 dragStart: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8894 dragStop: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8895 focus: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8896 open: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8897 resize: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8898 resizeStart: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8899 resizeStop: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8900 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8901
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8902 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8903 this.originalCss = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8904 display: this.element[0].style.display,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8905 width: this.element[0].style.width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8906 minHeight: this.element[0].style.minHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8907 maxHeight: this.element[0].style.maxHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8908 height: this.element[0].style.height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8909 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8910 this.originalPosition = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8911 parent: this.element.parent(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8912 index: this.element.parent().children().index( this.element )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8913 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8914 this.originalTitle = this.element.attr("title");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8915 this.options.title = this.options.title || this.originalTitle;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8916
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8917 this._createWrapper();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8918
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8919 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8920 .show()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8921 .removeAttr("title")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8922 .addClass("ui-dialog-content ui-widget-content")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8923 .appendTo( this.uiDialog );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8924
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8925 this._createTitlebar();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8926 this._createButtonPane();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8927
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8928 if ( this.options.draggable && $.fn.draggable ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8929 this._makeDraggable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8930 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8931 if ( this.options.resizable && $.fn.resizable ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8932 this._makeResizable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8933 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8934
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8935 this._isOpen = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8936 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8937
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8938 _init: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8939 if ( this.options.autoOpen ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8940 this.open();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8941 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8942 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8943
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8944 _appendTo: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8945 var element = this.options.appendTo;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8946 if ( element && (element.jquery || element.nodeType) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8947 return $( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8948 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8949 return this.document.find( element || "body" ).eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8950 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8951
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8952 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8953 var next,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8954 originalPosition = this.originalPosition;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8955
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8956 this._destroyOverlay();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8957
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8958 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8959 .removeUniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8960 .removeClass("ui-dialog-content ui-widget-content")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8961 .css( this.originalCss )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8962 // Without detaching first, the following becomes really slow
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8963 .detach();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8964
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8965 this.uiDialog.stop( true, true ).remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8966
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8967 if ( this.originalTitle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8968 this.element.attr( "title", this.originalTitle );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8969 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8970
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8971 next = originalPosition.parent.children().eq( originalPosition.index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8972 // Don't try to place the dialog next to itself (#8613)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8973 if ( next.length && next[0] !== this.element[0] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8974 next.before( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8975 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8976 originalPosition.parent.append( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8977 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8978 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8979
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8980 widget: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8981 return this.uiDialog;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8982 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8983
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8984 disable: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8985 enable: $.noop,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8986
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8987 close: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8988 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8989
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8990 if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8991 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8992 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8993
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8994 this._isOpen = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8995 this._destroyOverlay();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8996
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8997 if ( !this.opener.filter(":focusable").focus().length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8998 // Hiding a focused element doesn't trigger blur in WebKit
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8999 // so in case we have nothing to focus on, explicitly blur the active element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9000 // https://bugs.webkit.org/show_bug.cgi?id=47182
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9001 $( this.document[0].activeElement ).blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9002 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9003
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9004 this._hide( this.uiDialog, this.options.hide, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9005 that._trigger( "close", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9006 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9007 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9008
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9009 isOpen: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9010 return this._isOpen;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9011 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9012
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9013 moveToTop: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9014 this._moveToTop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9015 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9016
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9017 _moveToTop: function( event, silent ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9018 var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9019 if ( moved && !silent ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9020 this._trigger( "focus", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9021 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9022 return moved;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9023 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9024
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9025 open: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9026 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9027 if ( this._isOpen ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9028 if ( this._moveToTop() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9029 this._focusTabbable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9030 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9031 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9032 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9033
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9034 this._isOpen = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9035 this.opener = $( this.document[0].activeElement );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9036
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9037 this._size();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9038 this._position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9039 this._createOverlay();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9040 this._moveToTop( null, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9041 this._show( this.uiDialog, this.options.show, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9042 that._focusTabbable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9043 that._trigger("focus");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9044 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9045
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9046 this._trigger("open");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9047 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9048
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9049 _focusTabbable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9050 // Set focus to the first match:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9051 // 1. First element inside the dialog matching [autofocus]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9052 // 2. Tabbable element inside the content element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9053 // 3. Tabbable element inside the buttonpane
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9054 // 4. The close button
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9055 // 5. The dialog itself
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9056 var hasFocus = this.element.find("[autofocus]");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9057 if ( !hasFocus.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9058 hasFocus = this.element.find(":tabbable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9059 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9060 if ( !hasFocus.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9061 hasFocus = this.uiDialogButtonPane.find(":tabbable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9062 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9063 if ( !hasFocus.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9064 hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9065 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9066 if ( !hasFocus.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9067 hasFocus = this.uiDialog;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9068 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9069 hasFocus.eq( 0 ).focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9070 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9071
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9072 _keepFocus: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9073 function checkFocus() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9074 var activeElement = this.document[0].activeElement,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9075 isActive = this.uiDialog[0] === activeElement ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9076 $.contains( this.uiDialog[0], activeElement );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9077 if ( !isActive ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9078 this._focusTabbable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9079 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9080 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9081 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9082 checkFocus.call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9083 // support: IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9084 // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9085 // so we check again later
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9086 this._delay( checkFocus );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9087 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9088
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9089 _createWrapper: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9090 this.uiDialog = $("<div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9091 .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9092 this.options.dialogClass )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9093 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9094 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9095 // Setting tabIndex makes the div focusable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9096 tabIndex: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9097 role: "dialog"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9098 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9099 .appendTo( this._appendTo() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9100
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9101 this._on( this.uiDialog, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9102 keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9103 if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9104 event.keyCode === $.ui.keyCode.ESCAPE ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9105 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9106 this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9107 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9108 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9109
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9110 // prevent tabbing out of dialogs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9111 if ( event.keyCode !== $.ui.keyCode.TAB ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9112 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9113 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9114 var tabbables = this.uiDialog.find(":tabbable"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9115 first = tabbables.filter(":first"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9116 last = tabbables.filter(":last");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9117
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9118 if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9119 first.focus( 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9120 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9121 } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9122 last.focus( 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9123 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9124 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9125 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9126 mousedown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9127 if ( this._moveToTop( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9128 this._focusTabbable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9129 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9130 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9131 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9132
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9133 // We assume that any existing aria-describedby attribute means
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9134 // that the dialog content is marked up properly
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9135 // otherwise we brute force the content as the description
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9136 if ( !this.element.find("[aria-describedby]").length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9137 this.uiDialog.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9138 "aria-describedby": this.element.uniqueId().attr("id")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9139 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9140 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9141 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9142
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9143 _createTitlebar: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9144 var uiDialogTitle;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9145
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9146 this.uiDialogTitlebar = $("<div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9147 .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9148 .prependTo( this.uiDialog );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9149 this._on( this.uiDialogTitlebar, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9150 mousedown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9151 // Don't prevent click on close button (#8838)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9152 // Focusing a dialog that is partially scrolled out of view
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9153 // causes the browser to scroll it into view, preventing the click event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9154 if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9155 // Dialog isn't getting focus when dragging (#8063)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9156 this.uiDialog.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9157 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9159 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9160
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9161 this.uiDialogTitlebarClose = $("<button></button>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9162 .button({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9163 label: this.options.closeText,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9164 icons: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9165 primary: "ui-icon-closethick"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9166 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9167 text: false
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9168 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9169 .addClass("ui-dialog-titlebar-close")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9170 .appendTo( this.uiDialogTitlebar );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9171 this._on( this.uiDialogTitlebarClose, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9172 click: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9173 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9174 this.close( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9175 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9176 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9177
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9178 uiDialogTitle = $("<span>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9179 .uniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9180 .addClass("ui-dialog-title")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9181 .prependTo( this.uiDialogTitlebar );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9182 this._title( uiDialogTitle );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9183
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9184 this.uiDialog.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9185 "aria-labelledby": uiDialogTitle.attr("id")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9186 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9187 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9188
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9189 _title: function( title ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9190 if ( !this.options.title ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9191 title.html("&#160;");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9192 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9193 title.text( this.options.title );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9194 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9195
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9196 _createButtonPane: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9197 this.uiDialogButtonPane = $("<div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9198 .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9199
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9200 this.uiButtonSet = $("<div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9201 .addClass("ui-dialog-buttonset")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9202 .appendTo( this.uiDialogButtonPane );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9203
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9204 this._createButtons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9205 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9206
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9207 _createButtons: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9208 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9209 buttons = this.options.buttons;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9210
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9211 // if we already have a button pane, remove it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9212 this.uiDialogButtonPane.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9213 this.uiButtonSet.empty();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9214
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9215 if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9216 this.uiDialog.removeClass("ui-dialog-buttons");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9217 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9218 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9219
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9220 $.each( buttons, function( name, props ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9221 var click, buttonOptions;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9222 props = $.isFunction( props ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9223 { click: props, text: name } :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9224 props;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9225 // Default to a non-submitting button
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9226 props = $.extend( { type: "button" }, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9227 // Change the context for the click callback to be the main element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9228 click = props.click;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9229 props.click = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9230 click.apply( that.element[0], arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9231 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9232 buttonOptions = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9233 icons: props.icons,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9234 text: props.showText
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9235 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9236 delete props.icons;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9237 delete props.showText;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9238 $( "<button></button>", props )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9239 .button( buttonOptions )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9240 .appendTo( that.uiButtonSet );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9241 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9242 this.uiDialog.addClass("ui-dialog-buttons");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9243 this.uiDialogButtonPane.appendTo( this.uiDialog );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9244 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9245
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9246 _makeDraggable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9247 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9248 options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9249
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9250 function filteredUi( ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9251 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9252 position: ui.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9253 offset: ui.offset
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9254 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9255 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9256
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9257 this.uiDialog.draggable({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9258 cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9259 handle: ".ui-dialog-titlebar",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9260 containment: "document",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9261 start: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9262 $( this ).addClass("ui-dialog-dragging");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9263 that._blockFrames();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9264 that._trigger( "dragStart", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9265 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9266 drag: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9267 that._trigger( "drag", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9268 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9269 stop: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9270 options.position = [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9271 ui.position.left - that.document.scrollLeft(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9272 ui.position.top - that.document.scrollTop()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9273 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9274 $( this ).removeClass("ui-dialog-dragging");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9275 that._unblockFrames();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9276 that._trigger( "dragStop", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9277 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9278 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9279 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9280
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9281 _makeResizable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9282 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9283 options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9284 handles = options.resizable,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9285 // .ui-resizable has position: relative defined in the stylesheet
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9286 // but dialogs have to use absolute or fixed positioning
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9287 position = this.uiDialog.css("position"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9288 resizeHandles = typeof handles === "string" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9289 handles :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9290 "n,e,s,w,se,sw,ne,nw";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9291
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9292 function filteredUi( ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9293 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9294 originalPosition: ui.originalPosition,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9295 originalSize: ui.originalSize,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9296 position: ui.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9297 size: ui.size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9298 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9299 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9300
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9301 this.uiDialog.resizable({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9302 cancel: ".ui-dialog-content",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9303 containment: "document",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9304 alsoResize: this.element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9305 maxWidth: options.maxWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9306 maxHeight: options.maxHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9307 minWidth: options.minWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9308 minHeight: this._minHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9309 handles: resizeHandles,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9310 start: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9311 $( this ).addClass("ui-dialog-resizing");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9312 that._blockFrames();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9313 that._trigger( "resizeStart", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9314 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9315 resize: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9316 that._trigger( "resize", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9317 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9318 stop: function( event, ui ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9319 options.height = $( this ).height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9320 options.width = $( this ).width();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9321 $( this ).removeClass("ui-dialog-resizing");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9322 that._unblockFrames();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9323 that._trigger( "resizeStop", event, filteredUi( ui ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9324 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9325 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9326 .css( "position", position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9327 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9328
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9329 _minHeight: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9330 var options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9331
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9332 return options.height === "auto" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9333 options.minHeight :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9334 Math.min( options.minHeight, options.height );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9335 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9336
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9337 _position: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9338 // Need to show the dialog to get the actual offset in the position plugin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9339 var isVisible = this.uiDialog.is(":visible");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9340 if ( !isVisible ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9341 this.uiDialog.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9342 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9343 this.uiDialog.position( this.options.position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9344 if ( !isVisible ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9345 this.uiDialog.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9346 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9347 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9348
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9349 _setOptions: function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9350 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9351 resize = false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9352 resizableOptions = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9353
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9354 $.each( options, function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9355 that._setOption( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9356
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9357 if ( key in sizeRelatedOptions ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9358 resize = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9359 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9360 if ( key in resizableRelatedOptions ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9361 resizableOptions[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9362 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9363 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9364
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9365 if ( resize ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9366 this._size();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9367 this._position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9368 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9369 if ( this.uiDialog.is(":data(ui-resizable)") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9370 this.uiDialog.resizable( "option", resizableOptions );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9371 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9372 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9373
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9374 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9375 /*jshint maxcomplexity:15*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9376 var isDraggable, isResizable,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9377 uiDialog = this.uiDialog;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9378
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9379 if ( key === "dialogClass" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9380 uiDialog
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9381 .removeClass( this.options.dialogClass )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9382 .addClass( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9383 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9384
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9385 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9386 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9387 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9388
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9389 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9390
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9391 if ( key === "appendTo" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9392 this.uiDialog.appendTo( this._appendTo() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9393 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9394
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9395 if ( key === "buttons" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9396 this._createButtons();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9397 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9398
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9399 if ( key === "closeText" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9400 this.uiDialogTitlebarClose.button({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9401 // Ensure that we always pass a string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9402 label: "" + value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9403 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9404 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9405
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9406 if ( key === "draggable" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9407 isDraggable = uiDialog.is(":data(ui-draggable)");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9408 if ( isDraggable && !value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9409 uiDialog.draggable("destroy");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9410 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9411
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9412 if ( !isDraggable && value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9413 this._makeDraggable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9414 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9415 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9416
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9417 if ( key === "position" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9418 this._position();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9419 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9420
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9421 if ( key === "resizable" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9422 // currently resizable, becoming non-resizable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9423 isResizable = uiDialog.is(":data(ui-resizable)");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9424 if ( isResizable && !value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9425 uiDialog.resizable("destroy");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9426 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9427
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9428 // currently resizable, changing handles
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9429 if ( isResizable && typeof value === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9430 uiDialog.resizable( "option", "handles", value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9431 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9432
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9433 // currently non-resizable, becoming resizable
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9434 if ( !isResizable && value !== false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9435 this._makeResizable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9436 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9437 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9438
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9439 if ( key === "title" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9440 this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9441 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9442 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9444 _size: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9445 // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9446 // divs will both have width and height set, so we need to reset them
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9447 var nonContentHeight, minContentHeight, maxContentHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9448 options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9449
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9450 // Reset content sizing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9451 this.element.show().css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9452 width: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9453 minHeight: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9454 maxHeight: "none",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9455 height: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9456 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9457
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9458 if ( options.minWidth > options.width ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9459 options.width = options.minWidth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9460 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9461
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9462 // reset wrapper sizing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9463 // determine the height of all the non-content elements
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9464 nonContentHeight = this.uiDialog.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9465 height: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9466 width: options.width
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9467 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9468 .outerHeight();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9469 minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9470 maxContentHeight = typeof options.maxHeight === "number" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9471 Math.max( 0, options.maxHeight - nonContentHeight ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9472 "none";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9473
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9474 if ( options.height === "auto" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9475 this.element.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9476 minHeight: minContentHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9477 maxHeight: maxContentHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9478 height: "auto"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9479 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9480 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9481 this.element.height( Math.max( 0, options.height - nonContentHeight ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9482 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9483
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9484 if (this.uiDialog.is(":data(ui-resizable)") ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9485 this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9486 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9487 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9488
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9489 _blockFrames: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9490 this.iframeBlocks = this.document.find( "iframe" ).map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9491 var iframe = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9492
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9493 return $( "<div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9494 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9495 position: "absolute",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9496 width: iframe.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9497 height: iframe.outerHeight()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9498 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9499 .appendTo( iframe.parent() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9500 .offset( iframe.offset() )[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9501 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9502 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9503
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9504 _unblockFrames: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9505 if ( this.iframeBlocks ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9506 this.iframeBlocks.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9507 delete this.iframeBlocks;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9508 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9509 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9510
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9511 _allowInteraction: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9512 if ( $( event.target ).closest(".ui-dialog").length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9513 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9514 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9515
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9516 // TODO: Remove hack when datepicker implements
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9517 // the .ui-front logic (#8989)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9518 return !!$( event.target ).closest(".ui-datepicker").length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9519 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9520
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9521 _createOverlay: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9522 if ( !this.options.modal ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9523 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9524 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9525
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9526 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9527 widgetFullName = this.widgetFullName;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9528 if ( !$.ui.dialog.overlayInstances ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9529 // Prevent use of anchors and inputs.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9530 // We use a delay in case the overlay is created from an
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9531 // event that we're going to be cancelling. (#2804)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9532 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9533 // Handle .dialog().dialog("close") (#4065)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9534 if ( $.ui.dialog.overlayInstances ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9535 this.document.bind( "focusin.dialog", function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9536 if ( !that._allowInteraction( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9537 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9538 $(".ui-dialog:visible:last .ui-dialog-content")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9539 .data( widgetFullName )._focusTabbable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9540 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9541 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9542 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9543 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9544 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9545
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9546 this.overlay = $("<div>")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9547 .addClass("ui-widget-overlay ui-front")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9548 .appendTo( this._appendTo() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9549 this._on( this.overlay, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9550 mousedown: "_keepFocus"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9551 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9552 $.ui.dialog.overlayInstances++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9553 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9554
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9555 _destroyOverlay: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9556 if ( !this.options.modal ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9557 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9558 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9560 if ( this.overlay ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9561 $.ui.dialog.overlayInstances--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9562
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9563 if ( !$.ui.dialog.overlayInstances ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9564 this.document.unbind( "focusin.dialog" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9565 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9566 this.overlay.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9567 this.overlay = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9568 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9569 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9570 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9571
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9572 $.ui.dialog.overlayInstances = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9573
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9574 // DEPRECATED
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9575 if ( $.uiBackCompat !== false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9576 // position option with array notation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9577 // just override with old implementation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9578 $.widget( "ui.dialog", $.ui.dialog, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9579 _position: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9580 var position = this.options.position,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9581 myAt = [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9582 offset = [ 0, 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9583 isVisible;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9584
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9585 if ( position ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9586 if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9587 myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9588 if ( myAt.length === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9589 myAt[1] = myAt[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9590 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9591
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9592 $.each( [ "left", "top" ], function( i, offsetPosition ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9593 if ( +myAt[ i ] === myAt[ i ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9594 offset[ i ] = myAt[ i ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9595 myAt[ i ] = offsetPosition;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9596 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9597 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9598
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9599 position = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9600 my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9601 myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9602 at: myAt.join(" ")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9603 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9604 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9605
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9606 position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9607 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9608 position = $.ui.dialog.prototype.options.position;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9609 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9611 // need to show the dialog to get the actual offset in the position plugin
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9612 isVisible = this.uiDialog.is(":visible");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9613 if ( !isVisible ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9614 this.uiDialog.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9615 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9616 this.uiDialog.position( position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9617 if ( !isVisible ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9618 this.uiDialog.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9619 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9620 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9621 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9622 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9623
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9624 }( jQuery ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9625 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9626
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9627 $.widget( "ui.menu", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9628 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9629 defaultElement: "<ul>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9630 delay: 300,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9631 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9632 icons: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9633 submenu: "ui-icon-carat-1-e"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9634 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9635 menus: "ul",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9636 position: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9637 my: "left top",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9638 at: "right top"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9639 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9640 role: "menu",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9641
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9642 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9643 blur: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9644 focus: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9645 select: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9646 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9647
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9648 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9649 this.activeMenu = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9650 // flag used to prevent firing of the click handler
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9651 // as the event bubbles up through nested menus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9652 this.mouseHandled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9653 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9654 .uniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9655 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9656 .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9657 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9658 role: this.options.role,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9659 tabIndex: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9660 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9661 // need to catch all clicks on disabled menu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9662 // not possible through _on
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9663 .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9664 if ( this.options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9665 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9666 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9667 }, this ));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9668
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9669 if ( this.options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9670 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9671 .addClass( "ui-state-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9672 .attr( "aria-disabled", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9673 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9674
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9675 this._on({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9676 // Prevent focus from sticking to links inside menu after clicking
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9677 // them (focus should always stay on UL during navigation).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9678 "mousedown .ui-menu-item > a": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9679 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9680 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9681 "click .ui-state-disabled > a": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9682 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9683 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9684 "click .ui-menu-item:has(a)": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9685 var target = $( event.target ).closest( ".ui-menu-item" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9686 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9687 this.mouseHandled = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9688
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9689 this.select( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9690 // Open submenu on click
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9691 if ( target.has( ".ui-menu" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9692 this.expand( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9693 } else if ( !this.element.is( ":focus" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9694 // Redirect focus to the menu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9695 this.element.trigger( "focus", [ true ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9696
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9697 // If the active item is on the top level, let it stay active.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9698 // Otherwise, blur the active item since it is no longer visible.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9699 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9700 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9701 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9702 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9703 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9704 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9705 "mouseenter .ui-menu-item": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9706 var target = $( event.currentTarget );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9707 // Remove ui-state-active class from siblings of the newly focused menu item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9708 // to avoid a jump caused by adjacent elements both having a class with a border
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9709 target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9710 this.focus( event, target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9711 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9712 mouseleave: "collapseAll",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9713 "mouseleave .ui-menu": "collapseAll",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9714 focus: function( event, keepActiveItem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9715 // If there's already an active item, keep it active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9716 // If not, activate the first item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9717 var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9718
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9719 if ( !keepActiveItem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9720 this.focus( event, item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9721 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9722 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9723 blur: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9724 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9725 if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9726 this.collapseAll( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9727 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9728 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9729 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9730 keydown: "_keydown"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9731 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9733 this.refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9734
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9735 // Clicks outside of a menu collapse any open menus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9736 this._on( this.document, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9737 click: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9738 if ( !$( event.target ).closest( ".ui-menu" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9739 this.collapseAll( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9740 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9741
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9742 // Reset the mouseHandled flag
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9743 this.mouseHandled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9745 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9746 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9747
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9748 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9749 // Destroy (sub)menus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9750 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9751 .removeAttr( "aria-activedescendant" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9752 .find( ".ui-menu" ).addBack()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9753 .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9754 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9755 .removeAttr( "tabIndex" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9756 .removeAttr( "aria-labelledby" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9757 .removeAttr( "aria-expanded" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9758 .removeAttr( "aria-hidden" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9759 .removeAttr( "aria-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9760 .removeUniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9761 .show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9762
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9763 // Destroy menu items
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9764 this.element.find( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9765 .removeClass( "ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9766 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9767 .removeAttr( "aria-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9768 .children( "a" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9769 .removeUniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9770 .removeClass( "ui-corner-all ui-state-hover" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9771 .removeAttr( "tabIndex" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9772 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9773 .removeAttr( "aria-haspopup" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9774 .children().each( function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9775 var elem = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9776 if ( elem.data( "ui-menu-submenu-carat" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9777 elem.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9778 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9779 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9780
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9781 // Destroy menu dividers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9782 this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9783 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9784
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9785 _keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9786 /*jshint maxcomplexity:20*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9787 var match, prev, character, skip, regex,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9788 preventDefault = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9789
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9790 function escape( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9791 return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9792 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9794 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9795 case $.ui.keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9796 this.previousPage( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9797 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9798 case $.ui.keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9799 this.nextPage( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9800 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9801 case $.ui.keyCode.HOME:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9802 this._move( "first", "first", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9803 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9804 case $.ui.keyCode.END:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9805 this._move( "last", "last", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9806 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9807 case $.ui.keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9808 this.previous( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9809 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9810 case $.ui.keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9811 this.next( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9812 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9813 case $.ui.keyCode.LEFT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9814 this.collapse( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9815 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9816 case $.ui.keyCode.RIGHT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9817 if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9818 this.expand( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9819 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9820 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9821 case $.ui.keyCode.ENTER:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9822 case $.ui.keyCode.SPACE:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9823 this._activate( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9824 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9825 case $.ui.keyCode.ESCAPE:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9826 this.collapse( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9827 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9828 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9829 preventDefault = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9830 prev = this.previousFilter || "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9831 character = String.fromCharCode( event.keyCode );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9832 skip = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9833
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9834 clearTimeout( this.filterTimer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9835
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9836 if ( character === prev ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9837 skip = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9838 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9839 character = prev + character;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9840 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9841
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9842 regex = new RegExp( "^" + escape( character ), "i" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9843 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9844 return regex.test( $( this ).children( "a" ).text() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9845 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9846 match = skip && match.index( this.active.next() ) !== -1 ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9847 this.active.nextAll( ".ui-menu-item" ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9848 match;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9849
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9850 // If no matches on the current filter, reset to the last character pressed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9851 // to move down the menu to the first item that starts with that character
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9852 if ( !match.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9853 character = String.fromCharCode( event.keyCode );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9854 regex = new RegExp( "^" + escape( character ), "i" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9855 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9856 return regex.test( $( this ).children( "a" ).text() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9857 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9858 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9859
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9860 if ( match.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9861 this.focus( event, match );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9862 if ( match.length > 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9863 this.previousFilter = character;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9864 this.filterTimer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9865 delete this.previousFilter;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9866 }, 1000 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9867 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9868 delete this.previousFilter;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9869 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9870 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9871 delete this.previousFilter;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9872 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9873 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9874
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9875 if ( preventDefault ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9876 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9877 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9878 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9879
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9880 _activate: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9881 if ( !this.active.is( ".ui-state-disabled" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9882 if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9883 this.expand( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9884 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9885 this.select( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9886 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9887 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9888 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9889
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9890 refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9891 var menus,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9892 icon = this.options.icons.submenu,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9893 submenus = this.element.find( this.options.menus );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9894
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9895 // Initialize nested menus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9896 submenus.filter( ":not(.ui-menu)" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9897 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9898 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9899 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9900 role: this.options.role,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9901 "aria-hidden": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9902 "aria-expanded": "false"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9903 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9904 .each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9905 var menu = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9906 item = menu.prev( "a" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9907 submenuCarat = $( "<span>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9908 .addClass( "ui-menu-icon ui-icon " + icon )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9909 .data( "ui-menu-submenu-carat", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9910
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9911 item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9912 .attr( "aria-haspopup", "true" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9913 .prepend( submenuCarat );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9914 menu.attr( "aria-labelledby", item.attr( "id" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9915 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9916
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9917 menus = submenus.add( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9918
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9919 // Don't refresh list items that are already adapted
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9920 menus.children( ":not(.ui-menu-item):has(a)" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9921 .addClass( "ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9922 .attr( "role", "presentation" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9923 .children( "a" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9924 .uniqueId()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9925 .addClass( "ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9926 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9927 tabIndex: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9928 role: this._itemRole()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9929 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9930
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9931 // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9932 menus.children( ":not(.ui-menu-item)" ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9933 var item = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9934 // hyphen, em dash, en dash
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9935 if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9936 item.addClass( "ui-widget-content ui-menu-divider" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9937 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9938 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9939
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9940 // Add aria-disabled attribute to any disabled menu item
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9941 menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9942
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9943 // If the active item has been removed, blur the menu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9944 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9945 this.blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9946 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9947 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9948
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9949 _itemRole: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9950 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9951 menu: "menuitem",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9952 listbox: "option"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9953 }[ this.options.role ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9954 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9955
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9956 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9957 if ( key === "icons" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9958 this.element.find( ".ui-menu-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9959 .removeClass( this.options.icons.submenu )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9960 .addClass( value.submenu );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9961 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9962 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9963 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9964
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9965 focus: function( event, item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9966 var nested, focused;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9967 this.blur( event, event && event.type === "focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9968
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9969 this._scrollIntoView( item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9970
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9971 this.active = item.first();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9972 focused = this.active.children( "a" ).addClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9973 // Only update aria-activedescendant if there's a role
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9974 // otherwise we assume focus is managed elsewhere
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9975 if ( this.options.role ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9976 this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9977 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9978
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9979 // Highlight active parent menu item, if any
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9980 this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9981 .parent()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9982 .closest( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9983 .children( "a:first" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9984 .addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9985
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9986 if ( event && event.type === "keydown" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9987 this._close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9988 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9989 this.timer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9990 this._close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9991 }, this.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9992 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9993
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9994 nested = item.children( ".ui-menu" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9995 if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9996 this._startOpening(nested);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9997 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9998 this.activeMenu = item.parent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9999
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10000 this._trigger( "focus", event, { item: item } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10001 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10003 _scrollIntoView: function( item ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10004 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10005 if ( this._hasScroll() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10006 borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10007 paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10008 offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10009 scroll = this.activeMenu.scrollTop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10010 elementHeight = this.activeMenu.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10011 itemHeight = item.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10012
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10013 if ( offset < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10014 this.activeMenu.scrollTop( scroll + offset );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10015 } else if ( offset + itemHeight > elementHeight ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10016 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10017 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10018 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10019 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10020
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10021 blur: function( event, fromFocus ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10022 if ( !fromFocus ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10023 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10024 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10025
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10026 if ( !this.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10027 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10028 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10029
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10030 this.active.children( "a" ).removeClass( "ui-state-focus" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10031 this.active = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10032
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10033 this._trigger( "blur", event, { item: this.active } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10034 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10035
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10036 _startOpening: function( submenu ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10037 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10038
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10039 // Don't open if already open fixes a Firefox bug that caused a .5 pixel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10040 // shift in the submenu position when mousing over the carat icon
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10041 if ( submenu.attr( "aria-hidden" ) !== "true" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10042 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10043 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10044
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10045 this.timer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10046 this._close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10047 this._open( submenu );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10048 }, this.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10049 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10050
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10051 _open: function( submenu ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10052 var position = $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10053 of: this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10054 }, this.options.position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10055
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10056 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10057 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10058 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10059 .attr( "aria-hidden", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10061 submenu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10062 .show()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10063 .removeAttr( "aria-hidden" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10064 .attr( "aria-expanded", "true" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10065 .position( position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10066 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10067
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10068 collapseAll: function( event, all ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10069 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10070 this.timer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10071 // If we were passed an event, look for the submenu that contains the event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10072 var currentMenu = all ? this.element :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10073 $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10074
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10075 // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10076 if ( !currentMenu.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10077 currentMenu = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10078 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10079
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10080 this._close( currentMenu );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10081
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10082 this.blur( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10083 this.activeMenu = currentMenu;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10084 }, this.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10085 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10086
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10087 // With no arguments, closes the currently active menu - if nothing is active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10088 // it closes all menus. If passed an argument, it will search for menus BELOW
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10089 _close: function( startMenu ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10090 if ( !startMenu ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10091 startMenu = this.active ? this.active.parent() : this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10092 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10093
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10094 startMenu
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10095 .find( ".ui-menu" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10096 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10097 .attr( "aria-hidden", "true" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10098 .attr( "aria-expanded", "false" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10099 .end()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10100 .find( "a.ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10101 .removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10102 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10103
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10104 collapse: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10105 var newItem = this.active &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10106 this.active.parent().closest( ".ui-menu-item", this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10107 if ( newItem && newItem.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10108 this._close();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10109 this.focus( event, newItem );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10110 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10111 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10112
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10113 expand: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10114 var newItem = this.active &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10115 this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10116 .children( ".ui-menu " )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10117 .children( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10118 .first();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10119
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10120 if ( newItem && newItem.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10121 this._open( newItem.parent() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10122
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10123 // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10124 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10125 this.focus( event, newItem );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10126 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10127 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10128 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10129
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10130 next: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10131 this._move( "next", "first", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10132 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10133
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10134 previous: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10135 this._move( "prev", "last", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10136 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10137
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10138 isFirstItem: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10139 return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10140 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10141
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10142 isLastItem: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10143 return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10144 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10145
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10146 _move: function( direction, filter, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10147 var next;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10148 if ( this.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10149 if ( direction === "first" || direction === "last" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10150 next = this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10151 [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10152 .eq( -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10153 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10154 next = this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10155 [ direction + "All" ]( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10156 .eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10157 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10159 if ( !next || !next.length || !this.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10160 next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10161 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10162
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10163 this.focus( event, next );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10164 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10166 nextPage: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10167 var item, base, height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10168
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10169 if ( !this.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10170 this.next( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10171 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10172 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10173 if ( this.isLastItem() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10174 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10175 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10176 if ( this._hasScroll() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10177 base = this.active.offset().top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10178 height = this.element.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10179 this.active.nextAll( ".ui-menu-item" ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10180 item = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10181 return item.offset().top - base - height < 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10182 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10183
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10184 this.focus( event, item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10185 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10186 this.focus( event, this.activeMenu.children( ".ui-menu-item" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10187 [ !this.active ? "first" : "last" ]() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10188 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10189 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10190
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10191 previousPage: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10192 var item, base, height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10193 if ( !this.active ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10194 this.next( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10195 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10196 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10197 if ( this.isFirstItem() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10198 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10199 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10200 if ( this._hasScroll() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10201 base = this.active.offset().top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10202 height = this.element.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10203 this.active.prevAll( ".ui-menu-item" ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10204 item = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10205 return item.offset().top - base + height > 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10206 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10207
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10208 this.focus( event, item );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10209 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10210 this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10211 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10212 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10213
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10214 _hasScroll: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10215 return this.element.outerHeight() < this.element.prop( "scrollHeight" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10216 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10217
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10218 select: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10219 // TODO: It should never be possible to not have an active item at this
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10220 // point, but the tests don't trigger mouseenter before click.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10221 this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10222 var ui = { item: this.active };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10223 if ( !this.active.has( ".ui-menu" ).length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10224 this.collapseAll( event, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10225 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10226 this._trigger( "select", event, ui );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10227 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10228 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10229
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10230 }( jQuery ));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10231 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10232
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10233 $.widget( "ui.progressbar", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10234 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10235 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10236 max: 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10237 value: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10238
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10239 change: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10240 complete: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10241 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10242
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10243 min: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10245 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10246 // Constrain initial value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10247 this.oldValue = this.options.value = this._constrainedValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10248
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10249 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10250 .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10251 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10252 // Only set static values, aria-valuenow and aria-valuemax are
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10253 // set inside _refreshValue()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10254 role: "progressbar",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10255 "aria-valuemin": this.min
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10256 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10257
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10258 this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10259 .appendTo( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10260
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10261 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10262 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10263
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10264 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10265 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10266 .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10267 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10268 .removeAttr( "aria-valuemin" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10269 .removeAttr( "aria-valuemax" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10270 .removeAttr( "aria-valuenow" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10271
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10272 this.valueDiv.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10273 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10274
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10275 value: function( newValue ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10276 if ( newValue === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10277 return this.options.value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10278 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10279
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10280 this.options.value = this._constrainedValue( newValue );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10281 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10282 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10283
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10284 _constrainedValue: function( newValue ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10285 if ( newValue === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10286 newValue = this.options.value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10287 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10288
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10289 this.indeterminate = newValue === false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10290
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10291 // sanitize value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10292 if ( typeof newValue !== "number" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10293 newValue = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10294 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10295
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10296 return this.indeterminate ? false :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10297 Math.min( this.options.max, Math.max( this.min, newValue ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10298 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10299
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10300 _setOptions: function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10301 // Ensure "value" option is set after other values (like max)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10302 var value = options.value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10303 delete options.value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10304
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10305 this._super( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10306
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10307 this.options.value = this._constrainedValue( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10308 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10309 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10310
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10311 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10312 if ( key === "max" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10313 // Don't allow a max less than min
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10314 value = Math.max( this.min, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10315 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10316
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10317 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10318 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10319
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10320 _percentage: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10321 return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10322 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10323
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10324 _refreshValue: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10325 var value = this.options.value,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10326 percentage = this._percentage();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10327
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10328 this.valueDiv
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10329 .toggle( this.indeterminate || value > this.min )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10330 .toggleClass( "ui-corner-right", value === this.options.max )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10331 .width( percentage.toFixed(0) + "%" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10332
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10333 this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10334
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10335 if ( this.indeterminate ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10336 this.element.removeAttr( "aria-valuenow" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10337 if ( !this.overlayDiv ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10338 this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10339 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10340 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10341 this.element.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10342 "aria-valuemax": this.options.max,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10343 "aria-valuenow": value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10344 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10345 if ( this.overlayDiv ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10346 this.overlayDiv.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10347 this.overlayDiv = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10348 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10349 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10350
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10351 if ( this.oldValue !== value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10352 this.oldValue = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10353 this._trigger( "change" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10354 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10355 if ( value === this.options.max ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10356 this._trigger( "complete" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10357 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10358 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10359 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10360
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10361 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10362 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10363
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10364 // number of pages in a slider
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10365 // (how many times can you page up/down to go through the whole range)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10366 var numPages = 5;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10367
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10368 $.widget( "ui.slider", $.ui.mouse, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10369 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10370 widgetEventPrefix: "slide",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10371
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10372 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10373 animate: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10374 distance: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10375 max: 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10376 min: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10377 orientation: "horizontal",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10378 range: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10379 step: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10380 value: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10381 values: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10382
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10383 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10384 change: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10385 slide: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10386 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10387 stop: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10388 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10389
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10390 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10391 this._keySliding = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10392 this._mouseSliding = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10393 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10394 this._handleIndex = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10395 this._detectOrientation();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10396 this._mouseInit();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10397
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10398 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10399 .addClass( "ui-slider" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10400 " ui-slider-" + this.orientation +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10401 " ui-widget" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10402 " ui-widget-content" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10403 " ui-corner-all");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10404
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10405 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10406 this._setOption( "disabled", this.options.disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10407
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10408 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10409 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10410
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10411 _refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10412 this._createRange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10413 this._createHandles();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10414 this._setupEvents();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10415 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10416 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10417
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10418 _createHandles: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10419 var i, handleCount,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10420 options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10421 existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10422 handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10423 handles = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10424
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10425 handleCount = ( options.values && options.values.length ) || 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10426
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10427 if ( existingHandles.length > handleCount ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10428 existingHandles.slice( handleCount ).remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10429 existingHandles = existingHandles.slice( 0, handleCount );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10430 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10431
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10432 for ( i = existingHandles.length; i < handleCount; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10433 handles.push( handle );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10434 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10435
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10436 this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10437
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10438 this.handle = this.handles.eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10439
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10440 this.handles.each(function( i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10441 $( this ).data( "ui-slider-handle-index", i );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10442 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10443 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10444
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10445 _createRange: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10446 var options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10447 classes = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10448
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10449 if ( options.range ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10450 if ( options.range === true ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10451 if ( !options.values ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10452 options.values = [ this._valueMin(), this._valueMin() ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10453 } else if ( options.values.length && options.values.length !== 2 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10454 options.values = [ options.values[0], options.values[0] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10455 } else if ( $.isArray( options.values ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10456 options.values = options.values.slice(0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10457 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10458 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10459
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10460 if ( !this.range || !this.range.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10461 this.range = $( "<div></div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10462 .appendTo( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10463
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10464 classes = "ui-slider-range" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10465 // note: this isn't the most fittingly semantic framework class for this element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10466 // but worked best visually with a variety of themes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10467 " ui-widget-header ui-corner-all";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10468 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10469 this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10470 // Handle range switching from true to min/max
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10471 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10472 "left": "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10473 "bottom": ""
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10474 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10475 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10476
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10477 this.range.addClass( classes +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10478 ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10479 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10480 this.range = $([]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10481 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10482 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10483
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10484 _setupEvents: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10485 var elements = this.handles.add( this.range ).filter( "a" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10486 this._off( elements );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10487 this._on( elements, this._handleEvents );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10488 this._hoverable( elements );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10489 this._focusable( elements );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10490 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10491
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10492 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10493 this.handles.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10494 this.range.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10495
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10496 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10497 .removeClass( "ui-slider" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10498 " ui-slider-horizontal" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10499 " ui-slider-vertical" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10500 " ui-widget" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10501 " ui-widget-content" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10502 " ui-corner-all" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10503
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10504 this._mouseDestroy();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10505 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10506
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10507 _mouseCapture: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10508 var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10509 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10510 o = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10511
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10512 if ( o.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10513 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10514 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10515
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10516 this.elementSize = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10517 width: this.element.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10518 height: this.element.outerHeight()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10519 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10520 this.elementOffset = this.element.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10521
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10522 position = { x: event.pageX, y: event.pageY };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10523 normValue = this._normValueFromMouse( position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10524 distance = this._valueMax() - this._valueMin() + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10525 this.handles.each(function( i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10526 var thisDistance = Math.abs( normValue - that.values(i) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10527 if (( distance > thisDistance ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10528 ( distance === thisDistance &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10529 (i === that._lastChangedValue || that.values(i) === o.min ))) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10530 distance = thisDistance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10531 closestHandle = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10532 index = i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10533 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10534 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10536 allowed = this._start( event, index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10537 if ( allowed === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10538 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10539 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10540 this._mouseSliding = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10541
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10542 this._handleIndex = index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10543
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10544 closestHandle
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10545 .addClass( "ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10546 .focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10547
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10548 offset = closestHandle.offset();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10549 mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10550 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10551 left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10552 top: event.pageY - offset.top -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10553 ( closestHandle.height() / 2 ) -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10554 ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10555 ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10556 ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10557 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10558
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10559 if ( !this.handles.hasClass( "ui-state-hover" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10560 this._slide( event, index, normValue );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10561 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10562 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10563 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10564 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10565
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10566 _mouseStart: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10567 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10568 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10569
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10570 _mouseDrag: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10571 var position = { x: event.pageX, y: event.pageY },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10572 normValue = this._normValueFromMouse( position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10573
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10574 this._slide( event, this._handleIndex, normValue );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10575
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10576 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10577 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10578
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10579 _mouseStop: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10580 this.handles.removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10581 this._mouseSliding = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10582
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10583 this._stop( event, this._handleIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10584 this._change( event, this._handleIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10585
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10586 this._handleIndex = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10587 this._clickOffset = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10588 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10589
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10590 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10591 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10592
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10593 _detectOrientation: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10594 this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10595 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10596
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10597 _normValueFromMouse: function( position ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10598 var pixelTotal,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10599 pixelMouse,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10600 percentMouse,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10601 valueTotal,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10602 valueMouse;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10603
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10604 if ( this.orientation === "horizontal" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10605 pixelTotal = this.elementSize.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10606 pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10607 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10608 pixelTotal = this.elementSize.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10609 pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10610 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10611
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10612 percentMouse = ( pixelMouse / pixelTotal );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10613 if ( percentMouse > 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10614 percentMouse = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10615 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10616 if ( percentMouse < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10617 percentMouse = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10618 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10619 if ( this.orientation === "vertical" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10620 percentMouse = 1 - percentMouse;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10621 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10622
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10623 valueTotal = this._valueMax() - this._valueMin();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10624 valueMouse = this._valueMin() + percentMouse * valueTotal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10625
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10626 return this._trimAlignValue( valueMouse );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10627 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10628
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10629 _start: function( event, index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10630 var uiHash = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10631 handle: this.handles[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10632 value: this.value()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10633 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10634 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10635 uiHash.value = this.values( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10636 uiHash.values = this.values();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10637 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10638 return this._trigger( "start", event, uiHash );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10639 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10640
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10641 _slide: function( event, index, newVal ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10642 var otherVal,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10643 newValues,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10644 allowed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10645
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10646 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10647 otherVal = this.values( index ? 0 : 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10648
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10649 if ( ( this.options.values.length === 2 && this.options.range === true ) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10650 ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10651 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10652 newVal = otherVal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10653 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10654
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10655 if ( newVal !== this.values( index ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10656 newValues = this.values();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10657 newValues[ index ] = newVal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10658 // A slide can be canceled by returning false from the slide callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10659 allowed = this._trigger( "slide", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10660 handle: this.handles[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10661 value: newVal,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10662 values: newValues
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10663 } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10664 otherVal = this.values( index ? 0 : 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10665 if ( allowed !== false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10666 this.values( index, newVal, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10667 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10668 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10669 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10670 if ( newVal !== this.value() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10671 // A slide can be canceled by returning false from the slide callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10672 allowed = this._trigger( "slide", event, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10673 handle: this.handles[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10674 value: newVal
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10675 } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10676 if ( allowed !== false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10677 this.value( newVal );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10678 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10679 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10680 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10681 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10682
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10683 _stop: function( event, index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10684 var uiHash = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10685 handle: this.handles[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10686 value: this.value()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10687 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10688 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10689 uiHash.value = this.values( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10690 uiHash.values = this.values();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10691 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10692
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10693 this._trigger( "stop", event, uiHash );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10694 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10696 _change: function( event, index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10697 if ( !this._keySliding && !this._mouseSliding ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10698 var uiHash = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10699 handle: this.handles[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10700 value: this.value()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10701 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10702 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10703 uiHash.value = this.values( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10704 uiHash.values = this.values();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10705 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10706
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10707 //store the last changed value index for reference when handles overlap
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10708 this._lastChangedValue = index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10709
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10710 this._trigger( "change", event, uiHash );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10711 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10712 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10713
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10714 value: function( newValue ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10715 if ( arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10716 this.options.value = this._trimAlignValue( newValue );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10717 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10718 this._change( null, 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10719 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10720 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10721
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10722 return this._value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10723 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10724
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10725 values: function( index, newValue ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10726 var vals,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10727 newValues,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10728 i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10729
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10730 if ( arguments.length > 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10731 this.options.values[ index ] = this._trimAlignValue( newValue );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10732 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10733 this._change( null, index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10734 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10735 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10736
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10737 if ( arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10738 if ( $.isArray( arguments[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10739 vals = this.options.values;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10740 newValues = arguments[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10741 for ( i = 0; i < vals.length; i += 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10742 vals[ i ] = this._trimAlignValue( newValues[ i ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10743 this._change( null, i );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10745 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10746 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10747 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10748 return this._values( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10749 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10750 return this.value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10751 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10752 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10753 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10754 return this._values();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10755 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10756 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10757
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10758 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10759 var i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10760 valsLength = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10761
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10762 if ( key === "range" && this.options.range === true ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10763 if ( value === "min" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10764 this.options.value = this._values( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10765 this.options.values = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10766 } else if ( value === "max" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10767 this.options.value = this._values( this.options.values.length-1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10768 this.options.values = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10769 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10770 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10771
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10772 if ( $.isArray( this.options.values ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10773 valsLength = this.options.values.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10774 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10775
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10776 $.Widget.prototype._setOption.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10778 switch ( key ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10779 case "orientation":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10780 this._detectOrientation();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10781 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10782 .removeClass( "ui-slider-horizontal ui-slider-vertical" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10783 .addClass( "ui-slider-" + this.orientation );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10784 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10785 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10786 case "value":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10787 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10788 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10789 this._change( null, 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10790 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10791 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10792 case "values":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10793 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10794 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10795 for ( i = 0; i < valsLength; i += 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10796 this._change( null, i );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10797 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10798 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10799 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10800 case "min":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10801 case "max":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10802 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10803 this._refreshValue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10804 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10805 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10806 case "range":
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10807 this._animateOff = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10808 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10809 this._animateOff = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10810 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10811 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10812 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10813
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10814 //internal value getter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10815 // _value() returns value trimmed by min and max, aligned by step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10816 _value: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10817 var val = this.options.value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10818 val = this._trimAlignValue( val );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10819
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10820 return val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10821 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10823 //internal values getter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10824 // _values() returns array of values trimmed by min and max, aligned by step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10825 // _values( index ) returns single value trimmed by min and max, aligned by step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10826 _values: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10827 var val,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10828 vals,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10829 i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10830
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10831 if ( arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10832 val = this.options.values[ index ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10833 val = this._trimAlignValue( val );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10834
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10835 return val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10836 } else if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10837 // .slice() creates a copy of the array
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10838 // this copy gets trimmed by min and max and then returned
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10839 vals = this.options.values.slice();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10840 for ( i = 0; i < vals.length; i+= 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10841 vals[ i ] = this._trimAlignValue( vals[ i ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10842 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10843
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10844 return vals;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10845 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10846 return [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10847 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10848 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10849
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10850 // returns the step-aligned value that val is closest to, between (inclusive) min and max
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10851 _trimAlignValue: function( val ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10852 if ( val <= this._valueMin() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10853 return this._valueMin();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10854 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10855 if ( val >= this._valueMax() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10856 return this._valueMax();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10857 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10858 var step = ( this.options.step > 0 ) ? this.options.step : 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10859 valModStep = (val - this._valueMin()) % step,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10860 alignValue = val - valModStep;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10861
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10862 if ( Math.abs(valModStep) * 2 >= step ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10863 alignValue += ( valModStep > 0 ) ? step : ( -step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10864 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10865
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10866 // Since JavaScript has problems with large floats, round
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10867 // the final value to 5 digits after the decimal point (see #4124)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10868 return parseFloat( alignValue.toFixed(5) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10869 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10870
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10871 _valueMin: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10872 return this.options.min;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10873 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10874
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10875 _valueMax: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10876 return this.options.max;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10877 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10878
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10879 _refreshValue: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10880 var lastValPercent, valPercent, value, valueMin, valueMax,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10881 oRange = this.options.range,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10882 o = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10883 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10884 animate = ( !this._animateOff ) ? o.animate : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10885 _set = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10886
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10887 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10888 this.handles.each(function( i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10889 valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10890 _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10891 $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10892 if ( that.options.range === true ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10893 if ( that.orientation === "horizontal" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10894 if ( i === 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10895 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10896 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10897 if ( i === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10898 that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10899 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10900 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10901 if ( i === 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10902 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10903 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10904 if ( i === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10905 that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10906 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10907 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10908 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10909 lastValPercent = valPercent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10910 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10911 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10912 value = this.value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10913 valueMin = this._valueMin();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10914 valueMax = this._valueMax();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10915 valPercent = ( valueMax !== valueMin ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10916 ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10917 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10918 _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10919 this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10920
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10921 if ( oRange === "min" && this.orientation === "horizontal" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10922 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10923 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10924 if ( oRange === "max" && this.orientation === "horizontal" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10925 this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10926 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10927 if ( oRange === "min" && this.orientation === "vertical" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10928 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10929 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10930 if ( oRange === "max" && this.orientation === "vertical" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10931 this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10932 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10933 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10934 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10935
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10936 _handleEvents: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10937 keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10938 /*jshint maxcomplexity:25*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10939 var allowed, curVal, newVal, step,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10940 index = $( event.target ).data( "ui-slider-handle-index" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10941
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10942 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10943 case $.ui.keyCode.HOME:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10944 case $.ui.keyCode.END:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10945 case $.ui.keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10946 case $.ui.keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10947 case $.ui.keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10948 case $.ui.keyCode.RIGHT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10949 case $.ui.keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10950 case $.ui.keyCode.LEFT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10951 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10952 if ( !this._keySliding ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10953 this._keySliding = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10954 $( event.target ).addClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10955 allowed = this._start( event, index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10956 if ( allowed === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10957 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10958 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10959 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10960 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10961 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10962
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10963 step = this.options.step;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10964 if ( this.options.values && this.options.values.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10965 curVal = newVal = this.values( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10966 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10967 curVal = newVal = this.value();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10968 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10969
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10970 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10971 case $.ui.keyCode.HOME:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10972 newVal = this._valueMin();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10973 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10974 case $.ui.keyCode.END:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10975 newVal = this._valueMax();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10976 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10977 case $.ui.keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10978 newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10979 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10980 case $.ui.keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10981 newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10982 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10983 case $.ui.keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10984 case $.ui.keyCode.RIGHT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10985 if ( curVal === this._valueMax() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10986 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10987 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10988 newVal = this._trimAlignValue( curVal + step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10989 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10990 case $.ui.keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10991 case $.ui.keyCode.LEFT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10992 if ( curVal === this._valueMin() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10993 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10994 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10995 newVal = this._trimAlignValue( curVal - step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10996 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10997 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10998
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10999 this._slide( event, index, newVal );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11000 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11001 click: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11002 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11003 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11004 keyup: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11005 var index = $( event.target ).data( "ui-slider-handle-index" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11006
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11007 if ( this._keySliding ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11008 this._keySliding = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11009 this._stop( event, index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11010 this._change( event, index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11011 $( event.target ).removeClass( "ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11012 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11013 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11014 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11015
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11016 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11017
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11018 }(jQuery));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11019 (function( $ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11020
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11021 function modifier( fn ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11022 return function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11023 var previous = this.element.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11024 fn.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11025 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11026 if ( previous !== this.element.val() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11027 this._trigger( "change" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11028 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11029 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11030 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11031
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11032 $.widget( "ui.spinner", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11033 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11034 defaultElement: "<input>",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11035 widgetEventPrefix: "spin",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11036 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11037 culture: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11038 icons: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11039 down: "ui-icon-triangle-1-s",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11040 up: "ui-icon-triangle-1-n"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11041 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11042 incremental: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11043 max: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11044 min: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11045 numberFormat: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11046 page: 10,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11047 step: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11048
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11049 change: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11050 spin: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11051 start: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11052 stop: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11053 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11054
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11055 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11056 // handle string values that need to be parsed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11057 this._setOption( "max", this.options.max );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11058 this._setOption( "min", this.options.min );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11059 this._setOption( "step", this.options.step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11061 // format the value, but don't constrain
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11062 this._value( this.element.val(), true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11063
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11064 this._draw();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11065 this._on( this._events );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11066 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11067
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11068 // turning off autocomplete prevents the browser from remembering the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11069 // value when navigating through history, so we re-enable autocomplete
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11070 // if the page is unloaded before the widget is destroyed. #7790
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11071 this._on( this.window, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11072 beforeunload: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11073 this.element.removeAttr( "autocomplete" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11074 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11075 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11076 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11077
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11078 _getCreateOptions: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11079 var options = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11080 element = this.element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11081
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11082 $.each( [ "min", "max", "step" ], function( i, option ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11083 var value = element.attr( option );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11084 if ( value !== undefined && value.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11085 options[ option ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11086 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11087 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11088
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11089 return options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11090 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11091
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11092 _events: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11093 keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11094 if ( this._start( event ) && this._keydown( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11095 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11096 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11097 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11098 keyup: "_stop",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11099 focus: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11100 this.previous = this.element.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11101 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11102 blur: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11103 if ( this.cancelBlur ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11104 delete this.cancelBlur;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11105 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11106 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11107
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11108 this._stop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11109 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11110 if ( this.previous !== this.element.val() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11111 this._trigger( "change", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11112 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11113 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11114 mousewheel: function( event, delta ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11115 if ( !delta ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11116 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11117 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11118 if ( !this.spinning && !this._start( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11119 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11120 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11121
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11122 this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11123 clearTimeout( this.mousewheelTimer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11124 this.mousewheelTimer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11125 if ( this.spinning ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11126 this._stop( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11127 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11128 }, 100 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11129 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11130 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11131 "mousedown .ui-spinner-button": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11132 var previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11133
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11134 // We never want the buttons to have focus; whenever the user is
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11135 // interacting with the spinner, the focus should be on the input.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11136 // If the input is focused then this.previous is properly set from
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11137 // when the input first received focus. If the input is not focused
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11138 // then we need to set this.previous based on the value before spinning.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11139 previous = this.element[0] === this.document[0].activeElement ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11140 this.previous : this.element.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11141 function checkFocus() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11142 var isActive = this.element[0] === this.document[0].activeElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11143 if ( !isActive ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11144 this.element.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11145 this.previous = previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11146 // support: IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11147 // IE sets focus asynchronously, so we need to check if focus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11148 // moved off of the input because the user clicked on the button.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11149 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11150 this.previous = previous;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11151 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11152 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11153 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11154
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11155 // ensure focus is on (or stays on) the text field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11156 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11157 checkFocus.call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11158
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11159 // support: IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11160 // IE doesn't prevent moving focus even with event.preventDefault()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11161 // so we set a flag to know when we should ignore the blur event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11162 // and check (again) if focus moved off of the input.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11163 this.cancelBlur = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11164 this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11165 delete this.cancelBlur;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11166 checkFocus.call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11167 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11168
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11169 if ( this._start( event ) === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11170 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11171 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11172
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11173 this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11174 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11175 "mouseup .ui-spinner-button": "_stop",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11176 "mouseenter .ui-spinner-button": function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11177 // button will add ui-state-active if mouse was down while mouseleave and kept down
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11178 if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11179 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11180 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11181
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11182 if ( this._start( event ) === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11183 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11184 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11185 this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11186 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11187 // TODO: do we really want to consider this a stop?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11188 // shouldn't we just stop the repeater and wait until mouseup before
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11189 // we trigger the stop event?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11190 "mouseleave .ui-spinner-button": "_stop"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11191 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11192
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11193 _draw: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11194 var uiSpinner = this.uiSpinner = this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11195 .addClass( "ui-spinner-input" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11196 .attr( "autocomplete", "off" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11197 .wrap( this._uiSpinnerHtml() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11198 .parent()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11199 // add buttons
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11200 .append( this._buttonHtml() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11201
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11202 this.element.attr( "role", "spinbutton" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11203
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11204 // button bindings
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11205 this.buttons = uiSpinner.find( ".ui-spinner-button" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11206 .attr( "tabIndex", -1 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11207 .button()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11208 .removeClass( "ui-corner-all" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11209
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11210 // IE 6 doesn't understand height: 50% for the buttons
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11211 // unless the wrapper has an explicit height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11212 if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11213 uiSpinner.height() > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11214 uiSpinner.height( uiSpinner.height() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11215 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11216
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11217 // disable spinner if element was already disabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11218 if ( this.options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11219 this.disable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11220 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11221 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11222
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11223 _keydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11224 var options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11225 keyCode = $.ui.keyCode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11226
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11227 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11228 case keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11229 this._repeat( null, 1, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11230 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11231 case keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11232 this._repeat( null, -1, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11233 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11234 case keyCode.PAGE_UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11235 this._repeat( null, options.page, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11236 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11237 case keyCode.PAGE_DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11238 this._repeat( null, -options.page, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11239 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11240 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11241
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11242 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11243 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11245 _uiSpinnerHtml: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11246 return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11247 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11248
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11249 _buttonHtml: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11250 return "" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11251 "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11252 "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11253 "</a>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11254 "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11255 "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11256 "</a>";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11257 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11258
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11259 _start: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11260 if ( !this.spinning && this._trigger( "start", event ) === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11261 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11262 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11263
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11264 if ( !this.counter ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11265 this.counter = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11266 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11267 this.spinning = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11268 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11269 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11270
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11271 _repeat: function( i, steps, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11272 i = i || 500;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11273
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11274 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11275 this.timer = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11276 this._repeat( 40, steps, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11277 }, i );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11278
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11279 this._spin( steps * this.options.step, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11280 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11281
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11282 _spin: function( step, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11283 var value = this.value() || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11284
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11285 if ( !this.counter ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11286 this.counter = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11287 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11288
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11289 value = this._adjustValue( value + step * this._increment( this.counter ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11290
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11291 if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11292 this._value( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11293 this.counter++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11294 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11295 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11296
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11297 _increment: function( i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11298 var incremental = this.options.incremental;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11299
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11300 if ( incremental ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11301 return $.isFunction( incremental ) ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11302 incremental( i ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11303 Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11304 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11305
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11306 return 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11307 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11308
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11309 _precision: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11310 var precision = this._precisionOf( this.options.step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11311 if ( this.options.min !== null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11312 precision = Math.max( precision, this._precisionOf( this.options.min ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11313 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11314 return precision;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11315 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11316
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11317 _precisionOf: function( num ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11318 var str = num.toString(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11319 decimal = str.indexOf( "." );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11320 return decimal === -1 ? 0 : str.length - decimal - 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11321 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11322
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11323 _adjustValue: function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11324 var base, aboveMin,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11325 options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11326
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11327 // make sure we're at a valid step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11328 // - find out where we are relative to the base (min or 0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11329 base = options.min !== null ? options.min : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11330 aboveMin = value - base;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11331 // - round to the nearest step
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11332 aboveMin = Math.round(aboveMin / options.step) * options.step;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11333 // - rounding is based on 0, so adjust back to our base
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11334 value = base + aboveMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11335
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11336 // fix precision from bad JS floating point math
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11337 value = parseFloat( value.toFixed( this._precision() ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11338
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11339 // clamp the value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11340 if ( options.max !== null && value > options.max) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11341 return options.max;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11342 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11343 if ( options.min !== null && value < options.min ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11344 return options.min;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11345 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11346
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11347 return value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11348 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11349
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11350 _stop: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11351 if ( !this.spinning ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11352 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11353 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11354
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11355 clearTimeout( this.timer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11356 clearTimeout( this.mousewheelTimer );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11357 this.counter = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11358 this.spinning = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11359 this._trigger( "stop", event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11360 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11361
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11362 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11363 if ( key === "culture" || key === "numberFormat" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11364 var prevValue = this._parse( this.element.val() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11365 this.options[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11366 this.element.val( this._format( prevValue ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11367 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11368 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11369
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11370 if ( key === "max" || key === "min" || key === "step" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11371 if ( typeof value === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11372 value = this._parse( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11373 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11374 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11375 if ( key === "icons" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11376 this.buttons.first().find( ".ui-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11377 .removeClass( this.options.icons.up )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11378 .addClass( value.up );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11379 this.buttons.last().find( ".ui-icon" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11380 .removeClass( this.options.icons.down )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11381 .addClass( value.down );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11382 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11383
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11384 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11386 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11387 if ( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11388 this.element.prop( "disabled", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11389 this.buttons.button( "disable" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11390 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11391 this.element.prop( "disabled", false );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11392 this.buttons.button( "enable" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11393 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11394 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11395 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11396
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11397 _setOptions: modifier(function( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11398 this._super( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11399 this._value( this.element.val() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11400 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11401
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11402 _parse: function( val ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11403 if ( typeof val === "string" && val !== "" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11404 val = window.Globalize && this.options.numberFormat ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11405 Globalize.parseFloat( val, 10, this.options.culture ) : +val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11406 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11407 return val === "" || isNaN( val ) ? null : val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11408 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11409
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11410 _format: function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11411 if ( value === "" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11412 return "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11413 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11414 return window.Globalize && this.options.numberFormat ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11415 Globalize.format( value, this.options.numberFormat, this.options.culture ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11416 value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11417 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11418
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11419 _refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11420 this.element.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11421 "aria-valuemin": this.options.min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11422 "aria-valuemax": this.options.max,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11423 // TODO: what should we do with values that can't be parsed?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11424 "aria-valuenow": this._parse( this.element.val() )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11425 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11426 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11427
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11428 // update the value without triggering change
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11429 _value: function( value, allowAny ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11430 var parsed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11431 if ( value !== "" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11432 parsed = this._parse( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11433 if ( parsed !== null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11434 if ( !allowAny ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11435 parsed = this._adjustValue( parsed );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11436 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11437 value = this._format( parsed );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11438 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11439 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11440 this.element.val( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11441 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11442 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11444 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11445 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11446 .removeClass( "ui-spinner-input" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11447 .prop( "disabled", false )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11448 .removeAttr( "autocomplete" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11449 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11450 .removeAttr( "aria-valuemin" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11451 .removeAttr( "aria-valuemax" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11452 .removeAttr( "aria-valuenow" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11453 this.uiSpinner.replaceWith( this.element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11454 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11455
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11456 stepUp: modifier(function( steps ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11457 this._stepUp( steps );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11458 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11459 _stepUp: function( steps ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11460 if ( this._start() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11461 this._spin( (steps || 1) * this.options.step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11462 this._stop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11463 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11464 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11465
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11466 stepDown: modifier(function( steps ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11467 this._stepDown( steps );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11468 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11469 _stepDown: function( steps ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11470 if ( this._start() ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11471 this._spin( (steps || 1) * -this.options.step );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11472 this._stop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11473 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11474 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11475
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11476 pageUp: modifier(function( pages ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11477 this._stepUp( (pages || 1) * this.options.page );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11478 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11479
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11480 pageDown: modifier(function( pages ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11481 this._stepDown( (pages || 1) * this.options.page );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11482 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11483
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11484 value: function( newVal ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11485 if ( !arguments.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11486 return this._parse( this.element.val() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11487 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11488 modifier( this._value ).call( this, newVal );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11489 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11490
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11491 widget: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11492 return this.uiSpinner;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11493 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11494 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11495
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11496 }( jQuery ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11497 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11498
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11499 var tabId = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11500 rhash = /#.*$/;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11501
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11502 function getNextTabId() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11503 return ++tabId;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11504 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11505
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11506 function isLocal( anchor ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11507 return anchor.hash.length > 1 &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11508 decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11509 decodeURIComponent( location.href.replace( rhash, "" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11510 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11511
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11512 $.widget( "ui.tabs", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11513 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11514 delay: 300,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11515 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11516 active: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11517 collapsible: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11518 event: "click",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11519 heightStyle: "content",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11520 hide: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11521 show: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11522
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11523 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11524 activate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11525 beforeActivate: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11526 beforeLoad: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11527 load: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11528 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11529
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11530 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11531 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11532 options = this.options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11533
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11534 this.running = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11536 this.element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11537 .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11538 .toggleClass( "ui-tabs-collapsible", options.collapsible )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11539 // Prevent users from focusing disabled tabs via click
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11540 .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11541 if ( $( this ).is( ".ui-state-disabled" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11542 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11543 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11544 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11545 // support: IE <9
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11546 // Preventing the default action in mousedown doesn't prevent IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11547 // from focusing the element, so if the anchor gets focused, blur.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11548 // We don't have to worry about focusing the previously focused
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11549 // element since clicking on a non-focusable element should focus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11550 // the body anyway.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11551 .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11552 if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11553 this.blur();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11554 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11555 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11556
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11557 this._processTabs();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11558 options.active = this._initialActive();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11560 // Take disabling tabs via class attribute from HTML
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11561 // into account and update option properly.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11562 if ( $.isArray( options.disabled ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11563 options.disabled = $.unique( options.disabled.concat(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11564 $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11565 return that.tabs.index( li );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11566 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11567 ) ).sort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11568 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11569
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11570 // check for length avoids error when initializing empty list
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11571 if ( this.options.active !== false && this.anchors.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11572 this.active = this._findActive( options.active );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11573 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11574 this.active = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11575 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11576
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11577 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11578
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11579 if ( this.active.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11580 this.load( options.active );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11581 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11582 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11583
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11584 _initialActive: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11585 var active = this.options.active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11586 collapsible = this.options.collapsible,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11587 locationHash = location.hash.substring( 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11588
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11589 if ( active === null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11590 // check the fragment identifier in the URL
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11591 if ( locationHash ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11592 this.tabs.each(function( i, tab ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11593 if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11594 active = i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11595 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11596 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11597 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11598 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11599
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11600 // check for a tab marked active via a class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11601 if ( active === null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11602 active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11603 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11604
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11605 // no active tab, set to false
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11606 if ( active === null || active === -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11607 active = this.tabs.length ? 0 : false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11608 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11609 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11610
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11611 // handle numbers: negative, out of range
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11612 if ( active !== false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11613 active = this.tabs.index( this.tabs.eq( active ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11614 if ( active === -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11615 active = collapsible ? false : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11616 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11617 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11618
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11619 // don't allow collapsible: false and active: false
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11620 if ( !collapsible && active === false && this.anchors.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11621 active = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11622 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11623
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11624 return active;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11625 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11626
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11627 _getCreateEventData: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11628 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11629 tab: this.active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11630 panel: !this.active.length ? $() : this._getPanelForTab( this.active )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11631 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11632 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11634 _tabKeydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11635 /*jshint maxcomplexity:15*/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11636 var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11637 selectedIndex = this.tabs.index( focusedTab ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11638 goingForward = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11639
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11640 if ( this._handlePageNav( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11641 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11642 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11643
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11644 switch ( event.keyCode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11645 case $.ui.keyCode.RIGHT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11646 case $.ui.keyCode.DOWN:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11647 selectedIndex++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11648 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11649 case $.ui.keyCode.UP:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11650 case $.ui.keyCode.LEFT:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11651 goingForward = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11652 selectedIndex--;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11653 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11654 case $.ui.keyCode.END:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11655 selectedIndex = this.anchors.length - 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11656 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11657 case $.ui.keyCode.HOME:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11658 selectedIndex = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11659 break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11660 case $.ui.keyCode.SPACE:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11661 // Activate only, no collapsing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11662 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11663 clearTimeout( this.activating );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11664 this._activate( selectedIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11665 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11666 case $.ui.keyCode.ENTER:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11667 // Toggle (cancel delayed activation, allow collapsing)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11668 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11669 clearTimeout( this.activating );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11670 // Determine if we should collapse or activate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11671 this._activate( selectedIndex === this.options.active ? false : selectedIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11672 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11673 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11674 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11675 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11676
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11677 // Focus the appropriate tab, based on which key was pressed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11678 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11679 clearTimeout( this.activating );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11680 selectedIndex = this._focusNextTab( selectedIndex, goingForward );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11681
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11682 // Navigating with control key will prevent automatic activation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11683 if ( !event.ctrlKey ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11684 // Update aria-selected immediately so that AT think the tab is already selected.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11685 // Otherwise AT may confuse the user by stating that they need to activate the tab,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11686 // but the tab will already be activated by the time the announcement finishes.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11687 focusedTab.attr( "aria-selected", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11688 this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11689
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11690 this.activating = this._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11691 this.option( "active", selectedIndex );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11692 }, this.delay );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11693 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11694 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11696 _panelKeydown: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11697 if ( this._handlePageNav( event ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11698 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11699 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11700
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11701 // Ctrl+up moves focus to the current tab
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11702 if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11703 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11704 this.active.focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11705 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11706 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11707
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11708 // Alt+page up/down moves focus to the previous/next tab (and activates)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11709 _handlePageNav: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11710 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11711 this._activate( this._focusNextTab( this.options.active - 1, false ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11712 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11713 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11714 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11715 this._activate( this._focusNextTab( this.options.active + 1, true ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11716 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11717 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11718 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11719
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11720 _findNextTab: function( index, goingForward ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11721 var lastTabIndex = this.tabs.length - 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11722
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11723 function constrain() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11724 if ( index > lastTabIndex ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11725 index = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11726 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11727 if ( index < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11728 index = lastTabIndex;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11729 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11730 return index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11731 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11733 while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11734 index = goingForward ? index + 1 : index - 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11735 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11736
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11737 return index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11738 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11739
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11740 _focusNextTab: function( index, goingForward ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11741 index = this._findNextTab( index, goingForward );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11742 this.tabs.eq( index ).focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11743 return index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11744 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11745
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11746 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11747 if ( key === "active" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11748 // _activate() will handle invalid values and update this.options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11749 this._activate( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11750 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11751 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11752
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11753 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11754 // don't use the widget factory's disabled handling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11755 this._setupDisabled( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11756 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11757 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11758
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11759 this._super( key, value);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11760
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11761 if ( key === "collapsible" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11762 this.element.toggleClass( "ui-tabs-collapsible", value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11763 // Setting collapsible: false while collapsed; open first panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11764 if ( !value && this.options.active === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11765 this._activate( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11766 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11767 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11768
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11769 if ( key === "event" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11770 this._setupEvents( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11771 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11772
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11773 if ( key === "heightStyle" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11774 this._setupHeightStyle( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11775 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11776 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11778 _tabId: function( tab ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11779 return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11780 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11781
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11782 _sanitizeSelector: function( hash ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11783 return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11784 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11785
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11786 refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11787 var options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11788 lis = this.tablist.children( ":has(a[href])" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11789
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11790 // get disabled tabs from class attribute from HTML
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11791 // this will get converted to a boolean if needed in _refresh()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11792 options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11793 return lis.index( tab );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11794 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11795
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11796 this._processTabs();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11797
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11798 // was collapsed or no tabs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11799 if ( options.active === false || !this.anchors.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11800 options.active = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11801 this.active = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11802 // was active, but active tab is gone
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11803 } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11804 // all remaining tabs are disabled
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11805 if ( this.tabs.length === options.disabled.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11806 options.active = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11807 this.active = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11808 // activate previous tab
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11809 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11810 this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11811 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11812 // was active, active tab still exists
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11813 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11814 // make sure active index is correct
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11815 options.active = this.tabs.index( this.active );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11816 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11817
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11818 this._refresh();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11819 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11820
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11821 _refresh: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11822 this._setupDisabled( this.options.disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11823 this._setupEvents( this.options.event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11824 this._setupHeightStyle( this.options.heightStyle );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11825
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11826 this.tabs.not( this.active ).attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11827 "aria-selected": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11828 tabIndex: -1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11829 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11830 this.panels.not( this._getPanelForTab( this.active ) )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11831 .hide()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11832 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11833 "aria-expanded": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11834 "aria-hidden": "true"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11835 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11836
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11837 // Make sure one tab is in the tab order
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11838 if ( !this.active.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11839 this.tabs.eq( 0 ).attr( "tabIndex", 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11840 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11841 this.active
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11842 .addClass( "ui-tabs-active ui-state-active" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11843 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11844 "aria-selected": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11845 tabIndex: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11846 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11847 this._getPanelForTab( this.active )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11848 .show()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11849 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11850 "aria-expanded": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11851 "aria-hidden": "false"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11852 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11853 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11854 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11855
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11856 _processTabs: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11857 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11858
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11859 this.tablist = this._getList()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11860 .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11861 .attr( "role", "tablist" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11862
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11863 this.tabs = this.tablist.find( "> li:has(a[href])" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11864 .addClass( "ui-state-default ui-corner-top" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11865 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11866 role: "tab",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11867 tabIndex: -1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11868 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11869
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11870 this.anchors = this.tabs.map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11871 return $( "a", this )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11872 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11873 .addClass( "ui-tabs-anchor" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11874 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11875 role: "presentation",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11876 tabIndex: -1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11877 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11878
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11879 this.panels = $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11880
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11881 this.anchors.each(function( i, anchor ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11882 var selector, panel, panelId,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11883 anchorId = $( anchor ).uniqueId().attr( "id" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11884 tab = $( anchor ).closest( "li" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11885 originalAriaControls = tab.attr( "aria-controls" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11886
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11887 // inline tab
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11888 if ( isLocal( anchor ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11889 selector = anchor.hash;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11890 panel = that.element.find( that._sanitizeSelector( selector ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11891 // remote tab
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11892 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11893 panelId = that._tabId( tab );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11894 selector = "#" + panelId;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11895 panel = that.element.find( selector );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11896 if ( !panel.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11897 panel = that._createPanel( panelId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11898 panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11899 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11900 panel.attr( "aria-live", "polite" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11901 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11902
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11903 if ( panel.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11904 that.panels = that.panels.add( panel );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11905 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11906 if ( originalAriaControls ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11907 tab.data( "ui-tabs-aria-controls", originalAriaControls );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11908 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11909 tab.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11910 "aria-controls": selector.substring( 1 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11911 "aria-labelledby": anchorId
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11912 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11913 panel.attr( "aria-labelledby", anchorId );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11914 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11915
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11916 this.panels
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11917 .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11918 .attr( "role", "tabpanel" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11919 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11920
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11921 // allow overriding how to find the list for rare usage scenarios (#7715)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11922 _getList: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11923 return this.element.find( "ol,ul" ).eq( 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11924 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11925
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11926 _createPanel: function( id ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11927 return $( "<div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11928 .attr( "id", id )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11929 .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11930 .data( "ui-tabs-destroy", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11931 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11932
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11933 _setupDisabled: function( disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11934 if ( $.isArray( disabled ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11935 if ( !disabled.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11936 disabled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11937 } else if ( disabled.length === this.anchors.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11938 disabled = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11939 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11940 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11941
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11942 // disable tabs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11943 for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11944 if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11945 $( li )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11946 .addClass( "ui-state-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11947 .attr( "aria-disabled", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11948 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11949 $( li )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11950 .removeClass( "ui-state-disabled" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11951 .removeAttr( "aria-disabled" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11952 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11953 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11954
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11955 this.options.disabled = disabled;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11956 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11957
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11958 _setupEvents: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11959 var events = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11960 click: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11961 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11962 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11963 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11964 if ( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11965 $.each( event.split(" "), function( index, eventName ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11966 events[ eventName ] = "_eventHandler";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11967 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11968 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11969
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11970 this._off( this.anchors.add( this.tabs ).add( this.panels ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11971 this._on( this.anchors, events );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11972 this._on( this.tabs, { keydown: "_tabKeydown" } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11973 this._on( this.panels, { keydown: "_panelKeydown" } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11974
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11975 this._focusable( this.tabs );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11976 this._hoverable( this.tabs );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11977 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11978
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11979 _setupHeightStyle: function( heightStyle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11980 var maxHeight,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11981 parent = this.element.parent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11982
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11983 if ( heightStyle === "fill" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11984 maxHeight = parent.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11985 maxHeight -= this.element.outerHeight() - this.element.height();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11986
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11987 this.element.siblings( ":visible" ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11988 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11989 position = elem.css( "position" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11990
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11991 if ( position === "absolute" || position === "fixed" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11992 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11993 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11994 maxHeight -= elem.outerHeight( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11995 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11996
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11997 this.element.children().not( this.panels ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11998 maxHeight -= $( this ).outerHeight( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11999 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12000
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12001 this.panels.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12002 $( this ).height( Math.max( 0, maxHeight -
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12003 $( this ).innerHeight() + $( this ).height() ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12004 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12005 .css( "overflow", "auto" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12006 } else if ( heightStyle === "auto" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12007 maxHeight = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12008 this.panels.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12009 maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12010 }).height( maxHeight );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12011 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12012 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12013
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12014 _eventHandler: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12015 var options = this.options,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12016 active = this.active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12017 anchor = $( event.currentTarget ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12018 tab = anchor.closest( "li" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12019 clickedIsActive = tab[ 0 ] === active[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12020 collapsing = clickedIsActive && options.collapsible,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12021 toShow = collapsing ? $() : this._getPanelForTab( tab ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12022 toHide = !active.length ? $() : this._getPanelForTab( active ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12023 eventData = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12024 oldTab: active,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12025 oldPanel: toHide,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12026 newTab: collapsing ? $() : tab,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12027 newPanel: toShow
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12028 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12029
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12030 event.preventDefault();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12031
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12032 if ( tab.hasClass( "ui-state-disabled" ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12033 // tab is already loading
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12034 tab.hasClass( "ui-tabs-loading" ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12035 // can't switch durning an animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12036 this.running ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12037 // click on active header, but not collapsible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12038 ( clickedIsActive && !options.collapsible ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12039 // allow canceling activation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12040 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12041 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12042 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12043
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12044 options.active = collapsing ? false : this.tabs.index( tab );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12045
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12046 this.active = clickedIsActive ? $() : tab;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12047 if ( this.xhr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12048 this.xhr.abort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12049 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12050
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12051 if ( !toHide.length && !toShow.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12052 $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12053 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12054
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12055 if ( toShow.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12056 this.load( this.tabs.index( tab ), event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12057 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12058 this._toggle( event, eventData );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12059 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12061 // handles show/hide for selecting tabs
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12062 _toggle: function( event, eventData ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12063 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12064 toShow = eventData.newPanel,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12065 toHide = eventData.oldPanel;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12066
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12067 this.running = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12068
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12069 function complete() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12070 that.running = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12071 that._trigger( "activate", event, eventData );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12072 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12073
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12074 function show() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12075 eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12076
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12077 if ( toShow.length && that.options.show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12078 that._show( toShow, that.options.show, complete );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12079 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12080 toShow.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12081 complete();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12082 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12083 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12084
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12085 // start out by hiding, then showing, then completing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12086 if ( toHide.length && this.options.hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12087 this._hide( toHide, this.options.hide, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12088 eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12089 show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12090 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12091 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12092 eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12093 toHide.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12094 show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12095 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12096
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12097 toHide.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12098 "aria-expanded": "false",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12099 "aria-hidden": "true"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12100 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12101 eventData.oldTab.attr( "aria-selected", "false" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12102 // If we're switching tabs, remove the old tab from the tab order.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12103 // If we're opening from collapsed state, remove the previous tab from the tab order.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12104 // If we're collapsing, then keep the collapsing tab in the tab order.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12105 if ( toShow.length && toHide.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12106 eventData.oldTab.attr( "tabIndex", -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12107 } else if ( toShow.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12108 this.tabs.filter(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12109 return $( this ).attr( "tabIndex" ) === 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12110 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12111 .attr( "tabIndex", -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12112 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12113
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12114 toShow.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12115 "aria-expanded": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12116 "aria-hidden": "false"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12117 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12118 eventData.newTab.attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12119 "aria-selected": "true",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12120 tabIndex: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12121 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12122 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12123
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12124 _activate: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12125 var anchor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12126 active = this._findActive( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12127
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12128 // trying to activate the already active panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12129 if ( active[ 0 ] === this.active[ 0 ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12130 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12131 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12132
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12133 // trying to collapse, simulate a click on the current active header
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12134 if ( !active.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12135 active = this.active;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12136 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12137
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12138 anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12139 this._eventHandler({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12140 target: anchor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12141 currentTarget: anchor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12142 preventDefault: $.noop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12143 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12144 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12145
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12146 _findActive: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12147 return index === false ? $() : this.tabs.eq( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12148 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12149
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12150 _getIndex: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12151 // meta-function to give users option to provide a href string instead of a numerical index.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12152 if ( typeof index === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12153 index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12154 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12155
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12156 return index;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12157 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12158
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12159 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12160 if ( this.xhr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12161 this.xhr.abort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12162 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12163
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12164 this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12166 this.tablist
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12167 .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12168 .removeAttr( "role" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12169
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12170 this.anchors
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12171 .removeClass( "ui-tabs-anchor" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12172 .removeAttr( "role" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12173 .removeAttr( "tabIndex" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12174 .removeUniqueId();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12175
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12176 this.tabs.add( this.panels ).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12177 if ( $.data( this, "ui-tabs-destroy" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12178 $( this ).remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12179 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12180 $( this )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12181 .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12182 "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12183 .removeAttr( "tabIndex" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12184 .removeAttr( "aria-live" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12185 .removeAttr( "aria-busy" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12186 .removeAttr( "aria-selected" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12187 .removeAttr( "aria-labelledby" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12188 .removeAttr( "aria-hidden" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12189 .removeAttr( "aria-expanded" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12190 .removeAttr( "role" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12191 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12192 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12193
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12194 this.tabs.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12195 var li = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12196 prev = li.data( "ui-tabs-aria-controls" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12197 if ( prev ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12198 li
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12199 .attr( "aria-controls", prev )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12200 .removeData( "ui-tabs-aria-controls" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12201 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12202 li.removeAttr( "aria-controls" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12203 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12204 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12205
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12206 this.panels.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12207
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12208 if ( this.options.heightStyle !== "content" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12209 this.panels.css( "height", "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12210 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12211 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12212
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12213 enable: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12214 var disabled = this.options.disabled;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12215 if ( disabled === false ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12216 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12217 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12218
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12219 if ( index === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12220 disabled = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12221 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12222 index = this._getIndex( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12223 if ( $.isArray( disabled ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12224 disabled = $.map( disabled, function( num ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12225 return num !== index ? num : null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12226 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12227 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12228 disabled = $.map( this.tabs, function( li, num ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12229 return num !== index ? num : null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12230 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12231 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12232 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12233 this._setupDisabled( disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12234 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12235
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12236 disable: function( index ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12237 var disabled = this.options.disabled;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12238 if ( disabled === true ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12239 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12240 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12241
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12242 if ( index === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12243 disabled = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12244 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12245 index = this._getIndex( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12246 if ( $.inArray( index, disabled ) !== -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12247 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12248 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12249 if ( $.isArray( disabled ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12250 disabled = $.merge( [ index ], disabled ).sort();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12251 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12252 disabled = [ index ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12253 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12254 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12255 this._setupDisabled( disabled );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12256 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12257
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12258 load: function( index, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12259 index = this._getIndex( index );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12260 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12261 tab = this.tabs.eq( index ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12262 anchor = tab.find( ".ui-tabs-anchor" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12263 panel = this._getPanelForTab( tab ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12264 eventData = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12265 tab: tab,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12266 panel: panel
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12267 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12268
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12269 // not remote
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12270 if ( isLocal( anchor[ 0 ] ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12271 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12272 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12273
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12274 this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12275
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12276 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12277 // jQuery <1.8 returns false if the request is canceled in beforeSend,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12278 // but as of 1.8, $.ajax() always returns a jqXHR object.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12279 if ( this.xhr && this.xhr.statusText !== "canceled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12280 tab.addClass( "ui-tabs-loading" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12281 panel.attr( "aria-busy", "true" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12282
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12283 this.xhr
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12284 .success(function( response ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12285 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12286 // http://bugs.jquery.com/ticket/11778
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12287 setTimeout(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12288 panel.html( response );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12289 that._trigger( "load", event, eventData );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12290 }, 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12291 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12292 .complete(function( jqXHR, status ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12293 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12294 // http://bugs.jquery.com/ticket/11778
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12295 setTimeout(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12296 if ( status === "abort" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12297 that.panels.stop( false, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12298 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12299
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12300 tab.removeClass( "ui-tabs-loading" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12301 panel.removeAttr( "aria-busy" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12302
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12303 if ( jqXHR === that.xhr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12304 delete that.xhr;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12305 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12306 }, 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12307 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12308 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12309 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12310
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12311 _ajaxSettings: function( anchor, event, eventData ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12312 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12313 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12314 url: anchor.attr( "href" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12315 beforeSend: function( jqXHR, settings ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12316 return that._trigger( "beforeLoad", event,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12317 $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12318 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12319 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12320 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12321
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12322 _getPanelForTab: function( tab ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12323 var id = $( tab ).attr( "aria-controls" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12324 return this.element.find( this._sanitizeSelector( "#" + id ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12325 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12326 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12327
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12328 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12329 (function( $ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12331 var increments = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12332
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12333 function addDescribedBy( elem, id ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12334 var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12335 describedby.push( id );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12336 elem
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12337 .data( "ui-tooltip-id", id )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12338 .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12339 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12340
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12341 function removeDescribedBy( elem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12342 var id = elem.data( "ui-tooltip-id" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12343 describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12344 index = $.inArray( id, describedby );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12345 if ( index !== -1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12346 describedby.splice( index, 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12347 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12348
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12349 elem.removeData( "ui-tooltip-id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12350 describedby = $.trim( describedby.join( " " ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12351 if ( describedby ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12352 elem.attr( "aria-describedby", describedby );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12353 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12354 elem.removeAttr( "aria-describedby" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12355 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12356 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12357
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12358 $.widget( "ui.tooltip", {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12359 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12360 options: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12361 content: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12362 // support: IE<9, Opera in jQuery <1.7
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12363 // .text() can't accept undefined, so coerce to a string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12364 var title = $( this ).attr( "title" ) || "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12365 // Escape title, since we're going from an attribute to raw HTML
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12366 return $( "<a>" ).text( title ).html();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12367 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12368 hide: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12369 // Disabled elements have inconsistent behavior across browsers (#8661)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12370 items: "[title]:not([disabled])",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12371 position: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12372 my: "left top+15",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12373 at: "left bottom",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12374 collision: "flipfit flip"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12375 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12376 show: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12377 tooltipClass: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12378 track: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12379
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12380 // callbacks
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12381 close: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12382 open: null
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12383 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12384
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12385 _create: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12386 this._on({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12387 mouseover: "open",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12388 focusin: "open"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12389 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12390
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12391 // IDs of generated tooltips, needed for destroy
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12392 this.tooltips = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12393 // IDs of parent tooltips where we removed the title attribute
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12394 this.parents = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12395
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12396 if ( this.options.disabled ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12397 this._disable();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12398 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12399 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12400
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12401 _setOption: function( key, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12402 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12403
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12404 if ( key === "disabled" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12405 this[ value ? "_disable" : "_enable" ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12406 this.options[ key ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12407 // disable element style changes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12408 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12409 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12410
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12411 this._super( key, value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12412
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12413 if ( key === "content" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12414 $.each( this.tooltips, function( id, element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12415 that._updateContent( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12416 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12417 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12418 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12419
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12420 _disable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12421 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12422
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12423 // close open tooltips
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12424 $.each( this.tooltips, function( id, element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12425 var event = $.Event( "blur" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12426 event.target = event.currentTarget = element[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12427 that.close( event, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12428 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12429
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12430 // remove title attributes to prevent native tooltips
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12431 this.element.find( this.options.items ).addBack().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12432 var element = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12433 if ( element.is( "[title]" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12434 element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12435 .data( "ui-tooltip-title", element.attr( "title" ) )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12436 .attr( "title", "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12437 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12438 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12439 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12440
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12441 _enable: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12442 // restore title attributes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12443 this.element.find( this.options.items ).addBack().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12444 var element = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12445 if ( element.data( "ui-tooltip-title" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12446 element.attr( "title", element.data( "ui-tooltip-title" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12447 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12448 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12449 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12450
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12451 open: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12452 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12453 target = $( event ? event.target : this.element )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12454 // we need closest here due to mouseover bubbling,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12455 // but always pointing at the same event target
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12456 .closest( this.options.items );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12457
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12458 // No element to show a tooltip for or the tooltip is already open
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12459 if ( !target.length || target.data( "ui-tooltip-id" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12460 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12461 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12462
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12463 if ( target.attr( "title" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12464 target.data( "ui-tooltip-title", target.attr( "title" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12465 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12466
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12467 target.data( "ui-tooltip-open", true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12468
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12469 // kill parent tooltips, custom or native, for hover
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12470 if ( event && event.type === "mouseover" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12471 target.parents().each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12472 var parent = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12473 blurEvent;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12474 if ( parent.data( "ui-tooltip-open" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12475 blurEvent = $.Event( "blur" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12476 blurEvent.target = blurEvent.currentTarget = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12477 that.close( blurEvent, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12478 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12479 if ( parent.attr( "title" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12480 parent.uniqueId();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12481 that.parents[ this.id ] = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12482 element: this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12483 title: parent.attr( "title" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12484 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12485 parent.attr( "title", "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12486 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12487 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12489
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12490 this._updateContent( target, event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12491 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12492
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12493 _updateContent: function( target, event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12494 var content,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12495 contentOption = this.options.content,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12496 that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12497 eventType = event ? event.type : null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12498
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12499 if ( typeof contentOption === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12500 return this._open( event, target, contentOption );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12501 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12502
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12503 content = contentOption.call( target[0], function( response ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12504 // ignore async response if tooltip was closed already
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12505 if ( !target.data( "ui-tooltip-open" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12506 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12507 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12508 // IE may instantly serve a cached response for ajax requests
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12509 // delay this call to _open so the other call to _open runs first
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12510 that._delay(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12511 // jQuery creates a special event for focusin when it doesn't
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12512 // exist natively. To improve performance, the native event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12513 // object is reused and the type is changed. Therefore, we can't
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12514 // rely on the type being correct after the event finished
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12515 // bubbling, so we set it back to the previous value. (#8740)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12516 if ( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12517 event.type = eventType;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12518 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12519 this._open( event, target, response );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12520 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12521 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12522 if ( content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12523 this._open( event, target, content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12524 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12525 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12526
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12527 _open: function( event, target, content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12528 var tooltip, events, delayedShow,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12529 positionOption = $.extend( {}, this.options.position );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12530
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12531 if ( !content ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12532 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12533 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12534
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12535 // Content can be updated multiple times. If the tooltip already
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12536 // exists, then just update the content and bail.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12537 tooltip = this._find( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12538 if ( tooltip.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12539 tooltip.find( ".ui-tooltip-content" ).html( content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12540 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12541 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12542
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12543 // if we have a title, clear it to prevent the native tooltip
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12544 // we have to check first to avoid defining a title if none exists
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12545 // (we don't want to cause an element to start matching [title])
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12546 //
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12547 // We use removeAttr only for key events, to allow IE to export the correct
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12548 // accessible attributes. For mouse events, set to empty string to avoid
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12549 // native tooltip showing up (happens only when removing inside mouseover).
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12550 if ( target.is( "[title]" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12551 if ( event && event.type === "mouseover" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12552 target.attr( "title", "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12553 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12554 target.removeAttr( "title" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12555 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12556 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12557
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12558 tooltip = this._tooltip( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12559 addDescribedBy( target, tooltip.attr( "id" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12560 tooltip.find( ".ui-tooltip-content" ).html( content );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12561
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12562 function position( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12563 positionOption.of = event;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12564 if ( tooltip.is( ":hidden" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12565 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12566 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12567 tooltip.position( positionOption );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12568 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12569 if ( this.options.track && event && /^mouse/.test( event.type ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12570 this._on( this.document, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12571 mousemove: position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12572 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12573 // trigger once to override element-relative positioning
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12574 position( event );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12575 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12576 tooltip.position( $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12577 of: target
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12578 }, this.options.position ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12579 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12580
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12581 tooltip.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12582
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12583 this._show( tooltip, this.options.show );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12584 // Handle tracking tooltips that are shown with a delay (#8644). As soon
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12585 // as the tooltip is visible, position the tooltip using the most recent
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12586 // event.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12587 if ( this.options.show && this.options.show.delay ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12588 delayedShow = this.delayedShow = setInterval(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12589 if ( tooltip.is( ":visible" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12590 position( positionOption.of );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12591 clearInterval( delayedShow );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12592 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12593 }, $.fx.interval );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12594 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12595
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12596 this._trigger( "open", event, { tooltip: tooltip } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12597
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12598 events = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12599 keyup: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12600 if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12601 var fakeEvent = $.Event(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12602 fakeEvent.currentTarget = target[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12603 this.close( fakeEvent, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12604 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12605 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12606 remove: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12607 this._removeTooltip( tooltip );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12608 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12609 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12610 if ( !event || event.type === "mouseover" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12611 events.mouseleave = "close";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12612 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12613 if ( !event || event.type === "focusin" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12614 events.focusout = "close";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12615 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12616 this._on( true, target, events );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12617 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12618
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12619 close: function( event ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12620 var that = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12621 target = $( event ? event.currentTarget : this.element ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12622 tooltip = this._find( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12623
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12624 // disabling closes the tooltip, so we need to track when we're closing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12625 // to avoid an infinite loop in case the tooltip becomes disabled on close
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12626 if ( this.closing ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12627 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12628 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12629
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12630 // Clear the interval for delayed tracking tooltips
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12631 clearInterval( this.delayedShow );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12632
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12633 // only set title if we had one before (see comment in _open())
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12634 if ( target.data( "ui-tooltip-title" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12635 target.attr( "title", target.data( "ui-tooltip-title" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12636 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12638 removeDescribedBy( target );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12639
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12640 tooltip.stop( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12641 this._hide( tooltip, this.options.hide, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12642 that._removeTooltip( $( this ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12643 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12644
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12645 target.removeData( "ui-tooltip-open" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12646 this._off( target, "mouseleave focusout keyup" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12647 // Remove 'remove' binding only on delegated targets
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12648 if ( target[0] !== this.element[0] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12649 this._off( target, "remove" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12650 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12651 this._off( this.document, "mousemove" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12652
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12653 if ( event && event.type === "mouseleave" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12654 $.each( this.parents, function( id, parent ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12655 $( parent.element ).attr( "title", parent.title );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12656 delete that.parents[ id ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12657 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12658 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12659
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12660 this.closing = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12661 this._trigger( "close", event, { tooltip: tooltip } );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12662 this.closing = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12663 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12664
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12665 _tooltip: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12666 var id = "ui-tooltip-" + increments++,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12667 tooltip = $( "<div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12668 .attr({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12669 id: id,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12670 role: "tooltip"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12671 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12672 .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12673 ( this.options.tooltipClass || "" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12674 $( "<div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12675 .addClass( "ui-tooltip-content" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12676 .appendTo( tooltip );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12677 tooltip.appendTo( this.document[0].body );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12678 this.tooltips[ id ] = element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12679 return tooltip;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12680 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12681
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12682 _find: function( target ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12683 var id = target.data( "ui-tooltip-id" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12684 return id ? $( "#" + id ) : $();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12685 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12686
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12687 _removeTooltip: function( tooltip ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12688 tooltip.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12689 delete this.tooltips[ tooltip.attr( "id" ) ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12690 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12691
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12692 _destroy: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12693 var that = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12694
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12695 // close open tooltips
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12696 $.each( this.tooltips, function( id, element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12697 // Delegate to close method to handle common cleanup
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12698 var event = $.Event( "blur" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12699 event.target = event.currentTarget = element[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12700 that.close( event, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12701
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12702 // Remove immediately; destroying an open tooltip doesn't use the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12703 // hide animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12704 $( "#" + id ).remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12705
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12706 // Restore the title
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12707 if ( element.data( "ui-tooltip-title" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12708 element.attr( "title", element.data( "ui-tooltip-title" ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12709 element.removeData( "ui-tooltip-title" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12710 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12711 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12712 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12713 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12714
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12715 }( jQuery ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12716 (function($, undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12717
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12718 var dataSpace = "ui-effects-";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12719
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12720 $.effects = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12721 effect: {}
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12722 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12723
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12724 /*!
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12725 * jQuery Color Animations v2.1.2
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12726 * https://github.com/jquery/jquery-color
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12727 *
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12728 * Copyright 2013 jQuery Foundation and other contributors
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12729 * Released under the MIT license.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12730 * http://jquery.org/license
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12731 *
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12732 * Date: Wed Jan 16 08:47:09 2013 -0600
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12733 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12734 (function( jQuery, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12735
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12736 var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12737
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12738 // plusequals test for += 100 -= 100
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12739 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12740 // a set of RE's that can match strings and generate color tuples.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12741 stringParsers = [{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12742 re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12743 parse: function( execResult ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12744 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12745 execResult[ 1 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12746 execResult[ 2 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12747 execResult[ 3 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12748 execResult[ 4 ]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12749 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12750 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12751 }, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12752 re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12753 parse: function( execResult ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12754 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12755 execResult[ 1 ] * 2.55,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12756 execResult[ 2 ] * 2.55,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12757 execResult[ 3 ] * 2.55,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12758 execResult[ 4 ]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12759 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12760 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12761 }, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12762 // this regex ignores A-F because it's compared against an already lowercased string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12763 re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12764 parse: function( execResult ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12765 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12766 parseInt( execResult[ 1 ], 16 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12767 parseInt( execResult[ 2 ], 16 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12768 parseInt( execResult[ 3 ], 16 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12769 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12770 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12771 }, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12772 // this regex ignores A-F because it's compared against an already lowercased string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12773 re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12774 parse: function( execResult ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12775 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12776 parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12777 parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12778 parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12779 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12780 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12781 }, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12782 re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12783 space: "hsla",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12784 parse: function( execResult ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12785 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12786 execResult[ 1 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12787 execResult[ 2 ] / 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12788 execResult[ 3 ] / 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12789 execResult[ 4 ]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12790 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12791 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12792 }],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12794 // jQuery.Color( )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12795 color = jQuery.Color = function( color, green, blue, alpha ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12796 return new jQuery.Color.fn.parse( color, green, blue, alpha );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12797 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12798 spaces = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12799 rgba: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12800 props: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12801 red: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12802 idx: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12803 type: "byte"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12804 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12805 green: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12806 idx: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12807 type: "byte"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12808 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12809 blue: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12810 idx: 2,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12811 type: "byte"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12812 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12813 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12814 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12815
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12816 hsla: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12817 props: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12818 hue: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12819 idx: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12820 type: "degrees"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12821 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12822 saturation: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12823 idx: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12824 type: "percent"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12825 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12826 lightness: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12827 idx: 2,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12828 type: "percent"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12829 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12830 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12831 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12832 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12833 propTypes = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12834 "byte": {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12835 floor: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12836 max: 255
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12837 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12838 "percent": {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12839 max: 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12840 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12841 "degrees": {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12842 mod: 360,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12843 floor: true
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12844 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12845 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12846 support = color.support = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12847
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12848 // element for support tests
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12849 supportElem = jQuery( "<p>" )[ 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12850
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12851 // colors = jQuery.Color.names
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12852 colors,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12853
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12854 // local aliases of functions called often
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12855 each = jQuery.each;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12856
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12857 // determine rgba support immediately
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12858 supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12859 support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12860
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12861 // define cache name and alpha properties
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12862 // for rgba and hsla spaces
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12863 each( spaces, function( spaceName, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12864 space.cache = "_" + spaceName;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12865 space.props.alpha = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12866 idx: 3,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12867 type: "percent",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12868 def: 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12869 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12870 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12871
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12872 function clamp( value, prop, allowEmpty ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12873 var type = propTypes[ prop.type ] || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12874
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12875 if ( value == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12876 return (allowEmpty || !prop.def) ? null : prop.def;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12877 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12878
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12879 // ~~ is an short way of doing floor for positive numbers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12880 value = type.floor ? ~~value : parseFloat( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12881
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12882 // IE will pass in empty strings as value for alpha,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12883 // which will hit this case
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12884 if ( isNaN( value ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12885 return prop.def;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12886 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12887
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12888 if ( type.mod ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12889 // we add mod before modding to make sure that negatives values
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12890 // get converted properly: -10 -> 350
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12891 return (value + type.mod) % type.mod;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12892 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12893
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12894 // for now all property types without mod have min and max
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12895 return 0 > value ? 0 : type.max < value ? type.max : value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12896 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12897
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12898 function stringParse( string ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12899 var inst = color(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12900 rgba = inst._rgba = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12901
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12902 string = string.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12903
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12904 each( stringParsers, function( i, parser ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12905 var parsed,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12906 match = parser.re.exec( string ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12907 values = match && parser.parse( match ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12908 spaceName = parser.space || "rgba";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12909
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12910 if ( values ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12911 parsed = inst[ spaceName ]( values );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12912
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12913 // if this was an rgba parse the assignment might happen twice
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12914 // oh well....
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12915 inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12916 rgba = inst._rgba = parsed._rgba;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12917
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12918 // exit each( stringParsers ) here because we matched
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12919 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12920 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12921 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12922
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12923 // Found a stringParser that handled it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12924 if ( rgba.length ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12925
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12926 // if this came from a parsed string, force "transparent" when alpha is 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12927 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12928 if ( rgba.join() === "0,0,0,0" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12929 jQuery.extend( rgba, colors.transparent );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12930 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12931 return inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12932 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12933
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12934 // named colors
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12935 return colors[ string ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12936 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12937
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12938 color.fn = jQuery.extend( color.prototype, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12939 parse: function( red, green, blue, alpha ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12940 if ( red === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12941 this._rgba = [ null, null, null, null ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12942 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12943 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12944 if ( red.jquery || red.nodeType ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12945 red = jQuery( red ).css( green );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12946 green = undefined;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12947 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12948
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12949 var inst = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12950 type = jQuery.type( red ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12951 rgba = this._rgba = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12953 // more than 1 argument specified - assume ( red, green, blue, alpha )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12954 if ( green !== undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12955 red = [ red, green, blue, alpha ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12956 type = "array";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12957 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12958
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12959 if ( type === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12960 return this.parse( stringParse( red ) || colors._default );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12961 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12962
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12963 if ( type === "array" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12964 each( spaces.rgba.props, function( key, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12965 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12966 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12967 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12968 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12969
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12970 if ( type === "object" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12971 if ( red instanceof color ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12972 each( spaces, function( spaceName, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12973 if ( red[ space.cache ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12974 inst[ space.cache ] = red[ space.cache ].slice();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12975 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12976 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12977 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12978 each( spaces, function( spaceName, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12979 var cache = space.cache;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12980 each( space.props, function( key, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12981
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12982 // if the cache doesn't exist, and we know how to convert
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12983 if ( !inst[ cache ] && space.to ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12984
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12985 // if the value was null, we don't need to copy it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12986 // if the key was alpha, we don't need to copy it either
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12987 if ( key === "alpha" || red[ key ] == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12988 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12989 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12990 inst[ cache ] = space.to( inst._rgba );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12991 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12992
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12993 // this is the only case where we allow nulls for ALL properties.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12994 // call clamp with alwaysAllowEmpty
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12995 inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12996 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12997
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12998 // everything defined but alpha?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12999 if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13000 // use the default of 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13001 inst[ cache ][ 3 ] = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13002 if ( space.from ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13003 inst._rgba = space.from( inst[ cache ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13004 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13005 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13006 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13007 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13008 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13009 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13010 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13011 is: function( compare ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13012 var is = color( compare ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13013 same = true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13014 inst = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13015
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13016 each( spaces, function( _, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13017 var localCache,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13018 isCache = is[ space.cache ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13019 if (isCache) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13020 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13021 each( space.props, function( _, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13022 if ( isCache[ prop.idx ] != null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13023 same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13024 return same;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13025 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13026 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13027 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13028 return same;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13029 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13030 return same;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13031 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13032 _space: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13033 var used = [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13034 inst = this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13035 each( spaces, function( spaceName, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13036 if ( inst[ space.cache ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13037 used.push( spaceName );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13038 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13039 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13040 return used.pop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13041 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13042 transition: function( other, distance ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13043 var end = color( other ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13044 spaceName = end._space(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13045 space = spaces[ spaceName ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13046 startColor = this.alpha() === 0 ? color( "transparent" ) : this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13047 start = startColor[ space.cache ] || space.to( startColor._rgba ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13048 result = start.slice();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13049
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13050 end = end[ space.cache ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13051 each( space.props, function( key, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13052 var index = prop.idx,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13053 startValue = start[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13054 endValue = end[ index ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13055 type = propTypes[ prop.type ] || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13056
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13057 // if null, don't override start value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13058 if ( endValue === null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13059 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13060 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13061 // if null - use end
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13062 if ( startValue === null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13063 result[ index ] = endValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13064 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13065 if ( type.mod ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13066 if ( endValue - startValue > type.mod / 2 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13067 startValue += type.mod;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13068 } else if ( startValue - endValue > type.mod / 2 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13069 startValue -= type.mod;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13070 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13071 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13072 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13073 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13074 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13075 return this[ spaceName ]( result );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13076 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13077 blend: function( opaque ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13078 // if we are already opaque - return ourself
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13079 if ( this._rgba[ 3 ] === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13080 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13081 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13082
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13083 var rgb = this._rgba.slice(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13084 a = rgb.pop(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13085 blend = color( opaque )._rgba;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13086
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13087 return color( jQuery.map( rgb, function( v, i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13088 return ( 1 - a ) * blend[ i ] + a * v;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13089 }));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13090 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13091 toRgbaString: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13092 var prefix = "rgba(",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13093 rgba = jQuery.map( this._rgba, function( v, i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13094 return v == null ? ( i > 2 ? 1 : 0 ) : v;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13095 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13096
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13097 if ( rgba[ 3 ] === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13098 rgba.pop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13099 prefix = "rgb(";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13100 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13101
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13102 return prefix + rgba.join() + ")";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13103 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13104 toHslaString: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13105 var prefix = "hsla(",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13106 hsla = jQuery.map( this.hsla(), function( v, i ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13107 if ( v == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13108 v = i > 2 ? 1 : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13109 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13110
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13111 // catch 1 and 2
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13112 if ( i && i < 3 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13113 v = Math.round( v * 100 ) + "%";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13114 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13115 return v;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13116 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13117
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13118 if ( hsla[ 3 ] === 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13119 hsla.pop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13120 prefix = "hsl(";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13121 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13122 return prefix + hsla.join() + ")";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13123 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13124 toHexString: function( includeAlpha ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13125 var rgba = this._rgba.slice(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13126 alpha = rgba.pop();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13127
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13128 if ( includeAlpha ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13129 rgba.push( ~~( alpha * 255 ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13130 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13131
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13132 return "#" + jQuery.map( rgba, function( v ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13133
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13134 // default to 0 when nulls exist
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13135 v = ( v || 0 ).toString( 16 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13136 return v.length === 1 ? "0" + v : v;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13137 }).join("");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13138 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13139 toString: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13140 return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13141 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13142 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13143 color.fn.parse.prototype = color.fn;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13144
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13145 // hsla conversions adapted from:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13146 // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13147
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13148 function hue2rgb( p, q, h ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13149 h = ( h + 1 ) % 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13150 if ( h * 6 < 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13151 return p + (q - p) * h * 6;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13152 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13153 if ( h * 2 < 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13154 return q;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13155 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13156 if ( h * 3 < 2 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13157 return p + (q - p) * ((2/3) - h) * 6;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13159 return p;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13160 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13161
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13162 spaces.hsla.to = function ( rgba ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13163 if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13164 return [ null, null, null, rgba[ 3 ] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13165 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13166 var r = rgba[ 0 ] / 255,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13167 g = rgba[ 1 ] / 255,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13168 b = rgba[ 2 ] / 255,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13169 a = rgba[ 3 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13170 max = Math.max( r, g, b ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13171 min = Math.min( r, g, b ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13172 diff = max - min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13173 add = max + min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13174 l = add * 0.5,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13175 h, s;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13176
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13177 if ( min === max ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13178 h = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13179 } else if ( r === max ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13180 h = ( 60 * ( g - b ) / diff ) + 360;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13181 } else if ( g === max ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13182 h = ( 60 * ( b - r ) / diff ) + 120;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13183 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13184 h = ( 60 * ( r - g ) / diff ) + 240;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13185 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13186
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13187 // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13188 // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13189 if ( diff === 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13190 s = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13191 } else if ( l <= 0.5 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13192 s = diff / add;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13193 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13194 s = diff / ( 2 - add );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13195 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13196 return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13197 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13198
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13199 spaces.hsla.from = function ( hsla ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13200 if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13201 return [ null, null, null, hsla[ 3 ] ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13202 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13203 var h = hsla[ 0 ] / 360,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13204 s = hsla[ 1 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13205 l = hsla[ 2 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13206 a = hsla[ 3 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13207 q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13208 p = 2 * l - q;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13209
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13210 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13211 Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13212 Math.round( hue2rgb( p, q, h ) * 255 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13213 Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13214 a
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13215 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13216 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13217
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13218
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13219 each( spaces, function( spaceName, space ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13220 var props = space.props,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13221 cache = space.cache,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13222 to = space.to,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13223 from = space.from;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13224
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13225 // makes rgba() and hsla()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13226 color.fn[ spaceName ] = function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13227
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13228 // generate a cache for this space if it doesn't exist
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13229 if ( to && !this[ cache ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13230 this[ cache ] = to( this._rgba );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13231 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13232 if ( value === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13233 return this[ cache ].slice();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13234 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13235
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13236 var ret,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13237 type = jQuery.type( value ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13238 arr = ( type === "array" || type === "object" ) ? value : arguments,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13239 local = this[ cache ].slice();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13240
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13241 each( props, function( key, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13242 var val = arr[ type === "object" ? key : prop.idx ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13243 if ( val == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13244 val = local[ prop.idx ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13245 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13246 local[ prop.idx ] = clamp( val, prop );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13247 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13248
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13249 if ( from ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13250 ret = color( from( local ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13251 ret[ cache ] = local;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13252 return ret;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13253 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13254 return color( local );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13255 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13256 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13257
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13258 // makes red() green() blue() alpha() hue() saturation() lightness()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13259 each( props, function( key, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13260 // alpha is included in more than one space
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13261 if ( color.fn[ key ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13262 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13263 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13264 color.fn[ key ] = function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13265 var vtype = jQuery.type( value ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13266 fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13267 local = this[ fn ](),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13268 cur = local[ prop.idx ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13269 match;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13270
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13271 if ( vtype === "undefined" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13272 return cur;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13273 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13274
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13275 if ( vtype === "function" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13276 value = value.call( this, cur );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13277 vtype = jQuery.type( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13278 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13279 if ( value == null && prop.empty ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13280 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13281 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13282 if ( vtype === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13283 match = rplusequals.exec( value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13284 if ( match ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13285 value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13286 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13287 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13288 local[ prop.idx ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13289 return this[ fn ]( local );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13290 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13291 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13292 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13293
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13294 // add cssHook and .fx.step function for each named hook.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13295 // accept a space separated string of properties
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13296 color.hook = function( hook ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13297 var hooks = hook.split( " " );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13298 each( hooks, function( i, hook ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13299 jQuery.cssHooks[ hook ] = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13300 set: function( elem, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13301 var parsed, curElem,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13302 backgroundColor = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13303
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13304 if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13305 value = color( parsed || value );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13306 if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13307 curElem = hook === "backgroundColor" ? elem.parentNode : elem;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13308 while (
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13309 (backgroundColor === "" || backgroundColor === "transparent") &&
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13310 curElem && curElem.style
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13311 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13312 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13313 backgroundColor = jQuery.css( curElem, "backgroundColor" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13314 curElem = curElem.parentNode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13315 } catch ( e ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13316 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13317 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13318
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13319 value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13320 backgroundColor :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13321 "_default" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13322 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13323
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13324 value = value.toRgbaString();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13325 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13326 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13327 elem.style[ hook ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13328 } catch( e ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13329 // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13330 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13331 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13332 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13333 jQuery.fx.step[ hook ] = function( fx ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13334 if ( !fx.colorInit ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13335 fx.start = color( fx.elem, hook );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13336 fx.end = color( fx.end );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13337 fx.colorInit = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13338 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13339 jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13340 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13341 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13342
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13343 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13344
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13345 color.hook( stepHooks );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13346
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13347 jQuery.cssHooks.borderColor = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13348 expand: function( value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13349 var expanded = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13350
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13351 each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13352 expanded[ "border" + part + "Color" ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13353 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13354 return expanded;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13355 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13356 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13357
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13358 // Basic color names only.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13359 // Usage of any of the other color names requires adding yourself or including
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13360 // jquery.color.svg-names.js.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13361 colors = jQuery.Color.names = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13362 // 4.1. Basic color keywords
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13363 aqua: "#00ffff",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13364 black: "#000000",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13365 blue: "#0000ff",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13366 fuchsia: "#ff00ff",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13367 gray: "#808080",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13368 green: "#008000",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13369 lime: "#00ff00",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13370 maroon: "#800000",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13371 navy: "#000080",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13372 olive: "#808000",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13373 purple: "#800080",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13374 red: "#ff0000",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13375 silver: "#c0c0c0",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13376 teal: "#008080",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13377 white: "#ffffff",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13378 yellow: "#ffff00",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13379
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13380 // 4.2.3. "transparent" color keyword
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13381 transparent: [ null, null, null, 0 ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13382
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13383 _default: "#ffffff"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13384 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13385
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13386 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13387
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13388
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13389 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13390 /****************************** CLASS ANIMATIONS ******************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13391 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13392 (function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13393
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13394 var classAnimationActions = [ "add", "remove", "toggle" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13395 shorthandStyles = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13396 border: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13397 borderBottom: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13398 borderColor: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13399 borderLeft: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13400 borderRight: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13401 borderTop: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13402 borderWidth: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13403 margin: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13404 padding: 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13405 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13406
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13407 $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13408 $.fx.step[ prop ] = function( fx ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13409 if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13410 jQuery.style( fx.elem, prop, fx.end );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13411 fx.setAttr = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13412 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13413 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13414 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13415
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13416 function getElementStyles( elem ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13417 var key, len,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13418 style = elem.ownerDocument.defaultView ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13419 elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13420 elem.currentStyle,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13421 styles = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13422
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13423 if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13424 len = style.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13425 while ( len-- ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13426 key = style[ len ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13427 if ( typeof style[ key ] === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13428 styles[ $.camelCase( key ) ] = style[ key ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13429 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13430 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13431 // support: Opera, IE <9
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13432 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13433 for ( key in style ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13434 if ( typeof style[ key ] === "string" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13435 styles[ key ] = style[ key ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13436 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13437 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13438 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13439
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13440 return styles;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13441 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13442
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13444 function styleDifference( oldStyle, newStyle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13445 var diff = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13446 name, value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13447
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13448 for ( name in newStyle ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13449 value = newStyle[ name ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13450 if ( oldStyle[ name ] !== value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13451 if ( !shorthandStyles[ name ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13452 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13453 diff[ name ] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13454 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13455 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13456 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13457 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13458
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13459 return diff;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13460 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13461
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13462 // support: jQuery <1.8
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13463 if ( !$.fn.addBack ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13464 $.fn.addBack = function( selector ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13465 return this.add( selector == null ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13466 this.prevObject : this.prevObject.filter( selector )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13467 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13468 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13469 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13470
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13471 $.effects.animateClass = function( value, duration, easing, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13472 var o = $.speed( duration, easing, callback );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13473
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13474 return this.queue( function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13475 var animated = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13476 baseClass = animated.attr( "class" ) || "",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13477 applyClassChange,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13478 allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13479
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13480 // map the animated objects to store the original styles.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13481 allAnimations = allAnimations.map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13482 var el = $( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13483 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13484 el: el,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13485 start: getElementStyles( this )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13486 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13487 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13488
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13489 // apply class change
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13490 applyClassChange = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13491 $.each( classAnimationActions, function(i, action) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13492 if ( value[ action ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13493 animated[ action + "Class" ]( value[ action ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13494 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13495 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13496 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13497 applyClassChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13498
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13499 // map all animated objects again - calculate new styles and diff
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13500 allAnimations = allAnimations.map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13501 this.end = getElementStyles( this.el[ 0 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13502 this.diff = styleDifference( this.start, this.end );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13503 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13504 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13505
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13506 // apply original class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13507 animated.attr( "class", baseClass );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13508
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13509 // map all animated objects again - this time collecting a promise
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13510 allAnimations = allAnimations.map(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13511 var styleInfo = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13512 dfd = $.Deferred(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13513 opts = $.extend({}, o, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13514 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13515 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13516 dfd.resolve( styleInfo );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13517 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13518 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13519
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13520 this.el.animate( this.diff, opts );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13521 return dfd.promise();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13522 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13523
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13524 // once all animations have completed:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13525 $.when.apply( $, allAnimations.get() ).done(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13526
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13527 // set the final class
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13528 applyClassChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13529
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13530 // for each animated element,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13531 // clear all css properties that were animated
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13532 $.each( arguments, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13533 var el = this.el;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13534 $.each( this.diff, function(key) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13535 el.css( key, "" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13536 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13537 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13538
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13539 // this is guarnteed to be there if you use jQuery.speed()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13540 // it also handles dequeuing the next anim...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13541 o.complete.call( animated[ 0 ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13542 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13543 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13544 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13545
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13546 $.fn.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13547 addClass: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13548 return function( classNames, speed, easing, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13549 return speed ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13550 $.effects.animateClass.call( this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13551 { add: classNames }, speed, easing, callback ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13552 orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13553 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13554 })( $.fn.addClass ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13555
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13556 removeClass: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13557 return function( classNames, speed, easing, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13558 return arguments.length > 1 ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13559 $.effects.animateClass.call( this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13560 { remove: classNames }, speed, easing, callback ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13561 orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13562 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13563 })( $.fn.removeClass ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13564
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13565 toggleClass: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13566 return function( classNames, force, speed, easing, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13567 if ( typeof force === "boolean" || force === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13568 if ( !speed ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13569 // without speed parameter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13570 return orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13571 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13572 return $.effects.animateClass.call( this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13573 (force ? { add: classNames } : { remove: classNames }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13574 speed, easing, callback );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13575 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13576 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13577 // without force parameter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13578 return $.effects.animateClass.call( this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13579 { toggle: classNames }, force, speed, easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13580 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13581 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13582 })( $.fn.toggleClass ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13583
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13584 switchClass: function( remove, add, speed, easing, callback) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13585 return $.effects.animateClass.call( this, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13586 add: add,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13587 remove: remove
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13588 }, speed, easing, callback );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13589 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13590 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13591
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13592 })();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13593
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13594 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13595 /*********************************** EFFECTS **********************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13596 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13597
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13598 (function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13599
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13600 $.extend( $.effects, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13601 version: "1.10.3",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13602
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13603 // Saves a set of properties in a data storage
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13604 save: function( element, set ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13605 for( var i=0; i < set.length; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13606 if ( set[ i ] !== null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13607 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13608 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13609 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13610 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13611
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13612 // Restores a set of previously saved properties from a data storage
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13613 restore: function( element, set ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13614 var val, i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13615 for( i=0; i < set.length; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13616 if ( set[ i ] !== null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13617 val = element.data( dataSpace + set[ i ] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13618 // support: jQuery 1.6.2
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13619 // http://bugs.jquery.com/ticket/9917
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13620 // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13621 // We can't differentiate between "" and 0 here, so we just assume
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13622 // empty string since it's likely to be a more common value...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13623 if ( val === undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13624 val = "";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13625 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13626 element.css( set[ i ], val );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13627 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13628 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13629 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13630
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13631 setMode: function( el, mode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13632 if (mode === "toggle") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13633 mode = el.is( ":hidden" ) ? "show" : "hide";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13634 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13635 return mode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13636 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13637
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13638 // Translates a [top,left] array into a baseline value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13639 // this should be a little more flexible in the future to handle a string & hash
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13640 getBaseline: function( origin, original ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13641 var y, x;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13642 switch ( origin[ 0 ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13643 case "top": y = 0; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13644 case "middle": y = 0.5; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13645 case "bottom": y = 1; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13646 default: y = origin[ 0 ] / original.height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13647 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13648 switch ( origin[ 1 ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13649 case "left": x = 0; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13650 case "center": x = 0.5; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13651 case "right": x = 1; break;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13652 default: x = origin[ 1 ] / original.width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13653 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13654 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13655 x: x,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13656 y: y
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13657 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13658 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13659
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13660 // Wraps the element around a wrapper that copies position properties
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13661 createWrapper: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13662
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13663 // if the element is already wrapped, return it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13664 if ( element.parent().is( ".ui-effects-wrapper" )) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13665 return element.parent();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13666 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13667
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13668 // wrap the element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13669 var props = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13670 width: element.outerWidth(true),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13671 height: element.outerHeight(true),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13672 "float": element.css( "float" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13673 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13674 wrapper = $( "<div></div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13675 .addClass( "ui-effects-wrapper" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13676 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13677 fontSize: "100%",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13678 background: "transparent",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13679 border: "none",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13680 margin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13681 padding: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13682 }),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13683 // Store the size in case width/height are defined in % - Fixes #5245
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13684 size = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13685 width: element.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13686 height: element.height()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13687 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13688 active = document.activeElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13689
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13690 // support: Firefox
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13691 // Firefox incorrectly exposes anonymous content
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13692 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13693 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13694 active.id;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13695 } catch( e ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13696 active = document.body;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13697 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13698
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13699 element.wrap( wrapper );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13700
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13701 // Fixes #7595 - Elements lose focus when wrapped.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13702 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13703 $( active ).focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13704 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13705
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13706 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13707
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13708 // transfer positioning properties to the wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13709 if ( element.css( "position" ) === "static" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13710 wrapper.css({ position: "relative" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13711 element.css({ position: "relative" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13712 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13713 $.extend( props, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13714 position: element.css( "position" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13715 zIndex: element.css( "z-index" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13716 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13717 $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13718 props[ pos ] = element.css( pos );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13719 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13720 props[ pos ] = "auto";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13721 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13722 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13723 element.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13724 position: "relative",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13725 top: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13726 left: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13727 right: "auto",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13728 bottom: "auto"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13729 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13730 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13731 element.css(size);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13732
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13733 return wrapper.css( props ).show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13734 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13735
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13736 removeWrapper: function( element ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13737 var active = document.activeElement;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13738
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13739 if ( element.parent().is( ".ui-effects-wrapper" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13740 element.parent().replaceWith( element );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13741
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13742 // Fixes #7595 - Elements lose focus when wrapped.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13743 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13744 $( active ).focus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13745 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13746 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13747
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13748
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13749 return element;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13750 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13751
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13752 setTransition: function( element, list, factor, value ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13753 value = value || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13754 $.each( list, function( i, x ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13755 var unit = element.cssUnit( x );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13756 if ( unit[ 0 ] > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13757 value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13758 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13759 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13760 return value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13761 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13762 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13763
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13764 // return an effect options object for the given parameters:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13765 function _normalizeArguments( effect, options, speed, callback ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13766
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13767 // allow passing all options as the first parameter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13768 if ( $.isPlainObject( effect ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13769 options = effect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13770 effect = effect.effect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13771 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13772
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13773 // convert to an object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13774 effect = { effect: effect };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13775
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13776 // catch (effect, null, ...)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13777 if ( options == null ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13778 options = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13779 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13780
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13781 // catch (effect, callback)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13782 if ( $.isFunction( options ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13783 callback = options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13784 speed = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13785 options = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13786 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13787
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13788 // catch (effect, speed, ?)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13789 if ( typeof options === "number" || $.fx.speeds[ options ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13790 callback = speed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13791 speed = options;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13792 options = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13793 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13794
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13795 // catch (effect, options, callback)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13796 if ( $.isFunction( speed ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13797 callback = speed;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13798 speed = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13799 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13800
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13801 // add options to effect
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13802 if ( options ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13803 $.extend( effect, options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13804 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13805
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13806 speed = speed || options.duration;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13807 effect.duration = $.fx.off ? 0 :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13808 typeof speed === "number" ? speed :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13809 speed in $.fx.speeds ? $.fx.speeds[ speed ] :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13810 $.fx.speeds._default;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13811
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13812 effect.complete = callback || options.complete;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13813
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13814 return effect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13815 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13816
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13817 function standardAnimationOption( option ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13818 // Valid standard speeds (nothing, number, named speed)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13819 if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13820 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13821 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13823 // Invalid strings - treat as "normal" speed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13824 if ( typeof option === "string" && !$.effects.effect[ option ] ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13825 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13826 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13827
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13828 // Complete callback
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13829 if ( $.isFunction( option ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13830 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13831 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13832
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13833 // Options hash (but not naming an effect)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13834 if ( typeof option === "object" && !option.effect ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13835 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13836 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13837
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13838 // Didn't match any standard API
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13839 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13840 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13841
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13842 $.fn.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13843 effect: function( /* effect, options, speed, callback */ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13844 var args = _normalizeArguments.apply( this, arguments ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13845 mode = args.mode,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13846 queue = args.queue,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13847 effectMethod = $.effects.effect[ args.effect ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13848
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13849 if ( $.fx.off || !effectMethod ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13850 // delegate to the original method (e.g., .show()) if possible
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13851 if ( mode ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13852 return this[ mode ]( args.duration, args.complete );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13853 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13854 return this.each( function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13855 if ( args.complete ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13856 args.complete.call( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13857 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13858 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13859 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13860 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13861
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13862 function run( next ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13863 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13864 complete = args.complete,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13865 mode = args.mode;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13866
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13867 function done() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13868 if ( $.isFunction( complete ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13869 complete.call( elem[0] );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13870 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13871 if ( $.isFunction( next ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13872 next();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13873 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13874 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13875
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13876 // If the element already has the correct final state, delegate to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13877 // the core methods so the internal tracking of "olddisplay" works.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13878 if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13879 elem[ mode ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13880 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13881 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13882 effectMethod.call( elem[0], args, done );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13883 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13884 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13885
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13886 return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13887 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13888
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13889 show: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13890 return function( option ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13891 if ( standardAnimationOption( option ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13892 return orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13893 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13894 var args = _normalizeArguments.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13895 args.mode = "show";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13896 return this.effect.call( this, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13897 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13898 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13899 })( $.fn.show ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13900
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13901 hide: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13902 return function( option ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13903 if ( standardAnimationOption( option ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13904 return orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13905 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13906 var args = _normalizeArguments.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13907 args.mode = "hide";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13908 return this.effect.call( this, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13909 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13910 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13911 })( $.fn.hide ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13912
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13913 toggle: (function( orig ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13914 return function( option ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13915 if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13916 return orig.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13917 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13918 var args = _normalizeArguments.apply( this, arguments );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13919 args.mode = "toggle";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13920 return this.effect.call( this, args );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13921 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13922 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13923 })( $.fn.toggle ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13924
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13925 // helper functions
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13926 cssUnit: function(key) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13927 var style = this.css( key ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13928 val = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13929
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13930 $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13931 if ( style.indexOf( unit ) > 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13932 val = [ parseFloat( style ), unit ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13933 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13934 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13935 return val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13936 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13937 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13938
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13939 })();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13940
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13941 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13942 /*********************************** EASING ***********************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13943 /******************************************************************************/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13944
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13945 (function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13946
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13947 // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13948
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13949 var baseEasings = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13950
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13951 $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13952 baseEasings[ name ] = function( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13953 return Math.pow( p, i + 2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13954 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13955 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13956
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13957 $.extend( baseEasings, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13958 Sine: function ( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13959 return 1 - Math.cos( p * Math.PI / 2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13960 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13961 Circ: function ( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13962 return 1 - Math.sqrt( 1 - p * p );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13963 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13964 Elastic: function( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13965 return p === 0 || p === 1 ? p :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13966 -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13967 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13968 Back: function( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13969 return p * p * ( 3 * p - 2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13970 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13971 Bounce: function ( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13972 var pow2,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13973 bounce = 4;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13974
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13975 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13976 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13977 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13978 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13979
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13980 $.each( baseEasings, function( name, easeIn ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13981 $.easing[ "easeIn" + name ] = easeIn;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13982 $.easing[ "easeOut" + name ] = function( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13983 return 1 - easeIn( 1 - p );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13984 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13985 $.easing[ "easeInOut" + name ] = function( p ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13986 return p < 0.5 ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13987 easeIn( p * 2 ) / 2 :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13988 1 - easeIn( p * -2 + 2 ) / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13989 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13990 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13991
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13992 })();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13993
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13994 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13995 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13996
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13997 var rvertical = /up|down|vertical/,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13998 rpositivemotion = /up|left|vertical|horizontal/;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13999
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14000 $.effects.effect.blind = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14001 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14002 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14003 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14004 mode = $.effects.setMode( el, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14005 direction = o.direction || "up",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14006 vertical = rvertical.test( direction ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14007 ref = vertical ? "height" : "width",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14008 ref2 = vertical ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14009 motion = rpositivemotion.test( direction ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14010 animation = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14011 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14012 wrapper, distance, margin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14013
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14014 // if already wrapped, the wrapper's properties are my property. #6245
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14015 if ( el.parent().is( ".ui-effects-wrapper" ) ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14016 $.effects.save( el.parent(), props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14017 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14018 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14019 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14020 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14021 wrapper = $.effects.createWrapper( el ).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14022 overflow: "hidden"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14023 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14024
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14025 distance = wrapper[ ref ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14026 margin = parseFloat( wrapper.css( ref2 ) ) || 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14027
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14028 animation[ ref ] = show ? distance : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14029 if ( !motion ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14030 el
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14031 .css( vertical ? "bottom" : "right", 0 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14032 .css( vertical ? "top" : "left", "auto" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14033 .css({ position: "absolute" });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14034
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14035 animation[ ref2 ] = show ? margin : distance + margin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14036 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14037
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14038 // start at 0 if we are showing
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14039 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14040 wrapper.css( ref, 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14041 if ( ! motion ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14042 wrapper.css( ref2, margin + distance );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14043 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14044 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14045
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14046 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14047 wrapper.animate( animation, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14048 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14049 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14050 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14051 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14052 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14053 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14054 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14055 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14056 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14057 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14058 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14059 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14060
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14061 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14062
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14063 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14064 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14065
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14066 $.effects.effect.bounce = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14067 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14068 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14069
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14070 // defaults:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14071 mode = $.effects.setMode( el, o.mode || "effect" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14072 hide = mode === "hide",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14073 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14074 direction = o.direction || "up",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14075 distance = o.distance,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14076 times = o.times || 5,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14077
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14078 // number of internal animations
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14079 anims = times * 2 + ( show || hide ? 1 : 0 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14080 speed = o.duration / anims,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14081 easing = o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14082
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14083 // utility:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14084 ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14085 motion = ( direction === "up" || direction === "left" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14086 i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14087 upAnim,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14088 downAnim,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14089
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14090 // we will need to re-assemble the queue to stack our animations in place
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14091 queue = el.queue(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14092 queuelen = queue.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14093
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14094 // Avoid touching opacity to prevent clearType and PNG issues in IE
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14095 if ( show || hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14096 props.push( "opacity" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14097 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14098
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14099 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14100 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14101 $.effects.createWrapper( el ); // Create Wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14102
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14103 // default distance for the BIGGEST bounce is the outer Distance / 3
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14104 if ( !distance ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14105 distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14106 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14107
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14108 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14109 downAnim = { opacity: 1 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14110 downAnim[ ref ] = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14111
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14112 // if we are showing, force opacity 0 and set the initial position
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14113 // then do the "first" animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14114 el.css( "opacity", 0 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14115 .css( ref, motion ? -distance * 2 : distance * 2 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14116 .animate( downAnim, speed, easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14117 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14118
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14119 // start at the smallest distance if we are hiding
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14120 if ( hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14121 distance = distance / Math.pow( 2, times - 1 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14122 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14123
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14124 downAnim = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14125 downAnim[ ref ] = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14126 // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14127 for ( i = 0; i < times; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14128 upAnim = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14129 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14130
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14131 el.animate( upAnim, speed, easing )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14132 .animate( downAnim, speed, easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14133
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14134 distance = hide ? distance * 2 : distance / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14135 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14136
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14137 // Last Bounce when Hiding
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14138 if ( hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14139 upAnim = { opacity: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14140 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14141
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14142 el.animate( upAnim, speed, easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14143 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14144
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14145 el.queue(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14146 if ( hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14147 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14148 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14149 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14150 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14151 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14152 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14153
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14154 // inject all the animations we just queued to be first in line (after "inprogress")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14155 if ( queuelen > 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14156 queue.splice.apply( queue,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14157 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14158 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14159 el.dequeue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14160
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14161 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14162
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14163 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14164 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14166 $.effects.effect.clip = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14167 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14168 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14169 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14170 mode = $.effects.setMode( el, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14171 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14172 direction = o.direction || "vertical",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14173 vert = direction === "vertical",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14174 size = vert ? "height" : "width",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14175 position = vert ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14176 animation = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14177 wrapper, animate, distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14178
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14179 // Save & Show
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14180 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14181 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14182
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14183 // Create Wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14184 wrapper = $.effects.createWrapper( el ).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14185 overflow: "hidden"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14186 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14187 animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14188 distance = animate[ size ]();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14189
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14190 // Shift
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14191 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14192 animate.css( size, 0 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14193 animate.css( position, distance / 2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14194 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14195
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14196 // Create Animation Object:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14197 animation[ size ] = show ? distance : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14198 animation[ position ] = show ? 0 : distance / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14199
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14200 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14201 animate.animate( animation, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14202 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14203 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14204 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14205 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14206 if ( !show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14207 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14208 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14209 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14210 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14211 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14212 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14213 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14214
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14215 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14216
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14217 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14218 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14219
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14220 $.effects.effect.drop = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14221
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14222 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14223 props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14224 mode = $.effects.setMode( el, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14225 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14226 direction = o.direction || "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14227 ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14228 motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14229 animation = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14230 opacity: show ? 1 : 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14231 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14232 distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14233
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14234 // Adjust
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14235 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14236 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14237 $.effects.createWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14238
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14239 distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14240
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14241 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14242 el
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14243 .css( "opacity", 0 )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14244 .css( ref, motion === "pos" ? -distance : distance );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14245 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14246
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14247 // Animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14248 animation[ ref ] = ( show ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14249 ( motion === "pos" ? "+=" : "-=" ) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14250 ( motion === "pos" ? "-=" : "+=" ) ) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14251 distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14252
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14253 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14254 el.animate( animation, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14255 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14256 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14257 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14258 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14259 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14260 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14261 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14262 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14263 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14264 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14265 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14266 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14267 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14268
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14269 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14270 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14271
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14272 $.effects.effect.explode = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14273
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14274 var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14275 cells = rows,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14276 el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14277 mode = $.effects.setMode( el, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14278 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14279
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14280 // show and then visibility:hidden the element before calculating offset
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14281 offset = el.show().css( "visibility", "hidden" ).offset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14282
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14283 // width and height of a piece
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14284 width = Math.ceil( el.outerWidth() / cells ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14285 height = Math.ceil( el.outerHeight() / rows ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14286 pieces = [],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14287
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14288 // loop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14289 i, j, left, top, mx, my;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14290
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14291 // children animate complete:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14292 function childComplete() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14293 pieces.push( this );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14294 if ( pieces.length === rows * cells ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14295 animComplete();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14296 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14297 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14298
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14299 // clone the element for each row and cell.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14300 for( i = 0; i < rows ; i++ ) { // ===>
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14301 top = offset.top + i * height;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14302 my = i - ( rows - 1 ) / 2 ;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14303
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14304 for( j = 0; j < cells ; j++ ) { // |||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14305 left = offset.left + j * width;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14306 mx = j - ( cells - 1 ) / 2 ;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14307
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14308 // Create a clone of the now hidden main element that will be absolute positioned
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14309 // within a wrapper div off the -left and -top equal to size of our pieces
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14310 el
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14311 .clone()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14312 .appendTo( "body" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14313 .wrap( "<div></div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14314 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14315 position: "absolute",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14316 visibility: "visible",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14317 left: -j * width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14318 top: -i * height
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14319 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14320
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14321 // select the wrapper - make it overflow: hidden and absolute positioned based on
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14322 // where the original was located +left and +top equal to the size of pieces
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14323 .parent()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14324 .addClass( "ui-effects-explode" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14325 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14326 position: "absolute",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14327 overflow: "hidden",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14328 width: width,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14329 height: height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14330 left: left + ( show ? mx * width : 0 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14331 top: top + ( show ? my * height : 0 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14332 opacity: show ? 0 : 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14333 }).animate({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14334 left: left + ( show ? 0 : mx * width ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14335 top: top + ( show ? 0 : my * height ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14336 opacity: show ? 1 : 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14337 }, o.duration || 500, o.easing, childComplete );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14338 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14339 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14340
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14341 function animComplete() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14342 el.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14343 visibility: "visible"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14344 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14345 $( pieces ).remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14346 if ( !show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14347 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14348 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14349 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14350 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14351 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14352
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14353 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14354 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14355
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14356 $.effects.effect.fade = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14357 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14358 mode = $.effects.setMode( el, o.mode || "toggle" );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14359
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14360 el.animate({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14361 opacity: mode
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14362 }, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14363 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14364 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14365 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14366 complete: done
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14367 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14368 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14369
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14370 })( jQuery );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14371 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14372
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14373 $.effects.effect.fold = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14374
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14375 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14376 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14377 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14378 mode = $.effects.setMode( el, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14379 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14380 hide = mode === "hide",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14381 size = o.size || 15,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14382 percent = /([0-9]+)%/.exec( size ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14383 horizFirst = !!o.horizFirst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14384 widthFirst = show !== horizFirst,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14385 ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14386 duration = o.duration / 2,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14387 wrapper, distance,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14388 animation1 = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14389 animation2 = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14390
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14391 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14392 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14393
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14394 // Create Wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14395 wrapper = $.effects.createWrapper( el ).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14396 overflow: "hidden"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14397 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14398 distance = widthFirst ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14399 [ wrapper.width(), wrapper.height() ] :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14400 [ wrapper.height(), wrapper.width() ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14401
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14402 if ( percent ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14403 size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14404 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14405 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14406 wrapper.css( horizFirst ? {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14407 height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14408 width: size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14409 } : {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14410 height: size,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14411 width: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14412 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14413 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14414
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14415 // Animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14416 animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14417 animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14418
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14419 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14420 wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14421 .animate( animation1, duration, o.easing )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14422 .animate( animation2, duration, o.easing, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14423 if ( hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14424 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14425 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14426 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14427 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14428 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14429 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14430
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14431 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14432
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14433 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14434 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14435
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14436 $.effects.effect.highlight = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14437 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14438 props = [ "backgroundImage", "backgroundColor", "opacity" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14439 mode = $.effects.setMode( elem, o.mode || "show" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14440 animation = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14441 backgroundColor: elem.css( "backgroundColor" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14442 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14443
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14444 if (mode === "hide") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14445 animation.opacity = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14446 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14447
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14448 $.effects.save( elem, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14449
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14450 elem
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14451 .show()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14452 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14453 backgroundImage: "none",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14454 backgroundColor: o.color || "#ffff99"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14455 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14456 .animate( animation, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14457 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14458 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14459 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14460 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14461 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14462 elem.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14463 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14464 $.effects.restore( elem, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14465 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14466 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14467 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14468 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14469
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14470 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14471 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14472
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14473 $.effects.effect.pulsate = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14474 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14475 mode = $.effects.setMode( elem, o.mode || "show" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14476 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14477 hide = mode === "hide",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14478 showhide = ( show || mode === "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14479
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14480 // showing or hiding leaves of the "last" animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14481 anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14482 duration = o.duration / anims,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14483 animateTo = 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14484 queue = elem.queue(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14485 queuelen = queue.length,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14486 i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14487
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14488 if ( show || !elem.is(":visible")) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14489 elem.css( "opacity", 0 ).show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14490 animateTo = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14491 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14492
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14493 // anims - 1 opacity "toggles"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14494 for ( i = 1; i < anims; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14495 elem.animate({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14496 opacity: animateTo
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14497 }, duration, o.easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14498 animateTo = 1 - animateTo;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14499 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14500
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14501 elem.animate({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14502 opacity: animateTo
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14503 }, duration, o.easing);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14504
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14505 elem.queue(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14506 if ( hide ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14507 elem.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14508 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14509 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14510 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14511
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14512 // We just queued up "anims" animations, we need to put them next in the queue
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14513 if ( queuelen > 1 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14514 queue.splice.apply( queue,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14515 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14516 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14517 elem.dequeue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14518 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14519
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14520 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14521 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14522
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14523 $.effects.effect.puff = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14524 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14525 mode = $.effects.setMode( elem, o.mode || "hide" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14526 hide = mode === "hide",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14527 percent = parseInt( o.percent, 10 ) || 150,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14528 factor = percent / 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14529 original = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14530 height: elem.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14531 width: elem.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14532 outerHeight: elem.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14533 outerWidth: elem.outerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14534 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14535
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14536 $.extend( o, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14537 effect: "scale",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14538 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14539 fade: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14540 mode: mode,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14541 complete: done,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14542 percent: hide ? percent : 100,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14543 from: hide ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14544 original :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14545 {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14546 height: original.height * factor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14547 width: original.width * factor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14548 outerHeight: original.outerHeight * factor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14549 outerWidth: original.outerWidth * factor
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14550 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14551 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14552
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14553 elem.effect( o );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14554 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14555
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14556 $.effects.effect.scale = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14557
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14558 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14559 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14560 options = $.extend( true, {}, o ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14561 mode = $.effects.setMode( el, o.mode || "effect" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14562 percent = parseInt( o.percent, 10 ) ||
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14563 ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14564 direction = o.direction || "both",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14565 origin = o.origin,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14566 original = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14567 height: el.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14568 width: el.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14569 outerHeight: el.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14570 outerWidth: el.outerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14571 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14572 factor = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14573 y: direction !== "horizontal" ? (percent / 100) : 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14574 x: direction !== "vertical" ? (percent / 100) : 1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14575 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14576
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14577 // We are going to pass this effect to the size effect:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14578 options.effect = "size";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14579 options.queue = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14580 options.complete = done;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14581
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14582 // Set default origin and restore for show/hide
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14583 if ( mode !== "effect" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14584 options.origin = origin || ["middle","center"];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14585 options.restore = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14586 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14587
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14588 options.from = o.from || ( mode === "show" ? {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14589 height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14590 width: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14591 outerHeight: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14592 outerWidth: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14593 } : original );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14594 options.to = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14595 height: original.height * factor.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14596 width: original.width * factor.x,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14597 outerHeight: original.outerHeight * factor.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14598 outerWidth: original.outerWidth * factor.x
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14599 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14600
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14601 // Fade option to support puff
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14602 if ( options.fade ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14603 if ( mode === "show" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14604 options.from.opacity = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14605 options.to.opacity = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14606 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14607 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14608 options.from.opacity = 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14609 options.to.opacity = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14610 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14611 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14612
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14613 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14614 el.effect( options );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14615
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14616 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14617
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14618 $.effects.effect.size = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14619
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14620 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14621 var original, baseline, factor,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14622 el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14623 props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14624
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14625 // Always restore
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14626 props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14627
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14628 // Copy for children
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14629 props2 = [ "width", "height", "overflow" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14630 cProps = [ "fontSize" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14631 vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14632 hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14633
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14634 // Set options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14635 mode = $.effects.setMode( el, o.mode || "effect" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14636 restore = o.restore || mode !== "effect",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14637 scale = o.scale || "both",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14638 origin = o.origin || [ "middle", "center" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14639 position = el.css( "position" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14640 props = restore ? props0 : props1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14641 zero = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14642 height: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14643 width: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14644 outerHeight: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14645 outerWidth: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14646 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14647
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14648 if ( mode === "show" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14649 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14650 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14651 original = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14652 height: el.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14653 width: el.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14654 outerHeight: el.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14655 outerWidth: el.outerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14656 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14657
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14658 if ( o.mode === "toggle" && mode === "show" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14659 el.from = o.to || zero;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14660 el.to = o.from || original;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14661 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14662 el.from = o.from || ( mode === "show" ? zero : original );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14663 el.to = o.to || ( mode === "hide" ? zero : original );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14664 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14665
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14666 // Set scaling factor
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14667 factor = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14668 from: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14669 y: el.from.height / original.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14670 x: el.from.width / original.width
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14671 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14672 to: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14673 y: el.to.height / original.height,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14674 x: el.to.width / original.width
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14675 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14676 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14677
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14678 // Scale the css box
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14679 if ( scale === "box" || scale === "both" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14680
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14681 // Vertical props scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14682 if ( factor.from.y !== factor.to.y ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14683 props = props.concat( vProps );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14684 el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14685 el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14686 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14687
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14688 // Horizontal props scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14689 if ( factor.from.x !== factor.to.x ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14690 props = props.concat( hProps );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14691 el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14692 el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14693 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14694 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14695
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14696 // Scale the content
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14697 if ( scale === "content" || scale === "both" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14698
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14699 // Vertical props scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14700 if ( factor.from.y !== factor.to.y ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14701 props = props.concat( cProps ).concat( props2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14702 el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14703 el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14704 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14705 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14706
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14707 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14708 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14709 $.effects.createWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14710 el.css( "overflow", "hidden" ).css( el.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14711
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14712 // Adjust
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14713 if (origin) { // Calculate baseline shifts
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14714 baseline = $.effects.getBaseline( origin, original );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14715 el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14716 el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14717 el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14718 el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14719 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14720 el.css( el.from ); // set top & left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14721
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14722 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14723 if ( scale === "content" || scale === "both" ) { // Scale the children
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14724
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14725 // Add margins/font-size
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14726 vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14727 hProps = hProps.concat([ "marginLeft", "marginRight" ]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14728 props2 = props0.concat(vProps).concat(hProps);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14729
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14730 el.find( "*[width]" ).each( function(){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14731 var child = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14732 c_original = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14733 height: child.height(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14734 width: child.width(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14735 outerHeight: child.outerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14736 outerWidth: child.outerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14737 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14738 if (restore) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14739 $.effects.save(child, props2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14740 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14741
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14742 child.from = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14743 height: c_original.height * factor.from.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14744 width: c_original.width * factor.from.x,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14745 outerHeight: c_original.outerHeight * factor.from.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14746 outerWidth: c_original.outerWidth * factor.from.x
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14747 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14748 child.to = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14749 height: c_original.height * factor.to.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14750 width: c_original.width * factor.to.x,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14751 outerHeight: c_original.height * factor.to.y,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14752 outerWidth: c_original.width * factor.to.x
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14753 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14754
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14755 // Vertical props scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14756 if ( factor.from.y !== factor.to.y ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14757 child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14758 child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14759 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14760
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14761 // Horizontal props scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14762 if ( factor.from.x !== factor.to.x ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14763 child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14764 child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14765 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14766
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14767 // Animate children
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14768 child.css( child.from );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14769 child.animate( child.to, o.duration, o.easing, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14770
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14771 // Restore children
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14772 if ( restore ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14773 $.effects.restore( child, props2 );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14774 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14775 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14776 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14777 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14778
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14779 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14780 el.animate( el.to, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14781 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14782 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14783 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14784 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14785 if ( el.to.opacity === 0 ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14786 el.css( "opacity", el.from.opacity );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14787 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14788 if( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14789 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14790 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14791 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14792 if ( !restore ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14794 // we need to calculate our new positioning based on the scaling
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14795 if ( position === "static" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14796 el.css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14797 position: "relative",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14798 top: el.to.top,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14799 left: el.to.left
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14800 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14801 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14802 $.each([ "top", "left" ], function( idx, pos ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14803 el.css( pos, function( _, str ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14804 var val = parseInt( str, 10 ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14805 toRef = idx ? el.to.left : el.to.top;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14806
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14807 // if original was "auto", recalculate the new value from wrapper
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14808 if ( str === "auto" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14809 return toRef + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14810 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14811
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14812 return val + toRef + "px";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14813 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14814 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14815 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14816 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14817
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14818 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14819 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14820 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14821 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14823 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14824
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14825 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14826 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14827
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14828 $.effects.effect.shake = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14829
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14830 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14831 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14832 mode = $.effects.setMode( el, o.mode || "effect" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14833 direction = o.direction || "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14834 distance = o.distance || 20,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14835 times = o.times || 3,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14836 anims = times * 2 + 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14837 speed = Math.round(o.duration/anims),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14838 ref = (direction === "up" || direction === "down") ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14839 positiveMotion = (direction === "up" || direction === "left"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14840 animation = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14841 animation1 = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14842 animation2 = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14843 i,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14844
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14845 // we will need to re-assemble the queue to stack our animations in place
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14846 queue = el.queue(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14847 queuelen = queue.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14848
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14849 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14850 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14851 $.effects.createWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14852
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14853 // Animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14854 animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14855 animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14856 animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14857
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14858 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14859 el.animate( animation, speed, o.easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14860
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14861 // Shakes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14862 for ( i = 1; i < times; i++ ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14863 el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14864 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14865 el
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14866 .animate( animation1, speed, o.easing )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14867 .animate( animation, speed / 2, o.easing )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14868 .queue(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14869 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14870 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14871 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14872 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14873 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14874 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14875 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14876
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14877 // inject all the animations we just queued to be first in line (after "inprogress")
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14878 if ( queuelen > 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14879 queue.splice.apply( queue,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14880 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14881 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14882 el.dequeue();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14883
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14884 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14885
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14886 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14887 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14888
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14889 $.effects.effect.slide = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14890
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14891 // Create element
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14892 var el = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14893 props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14894 mode = $.effects.setMode( el, o.mode || "show" ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14895 show = mode === "show",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14896 direction = o.direction || "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14897 ref = (direction === "up" || direction === "down") ? "top" : "left",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14898 positiveMotion = (direction === "up" || direction === "left"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14899 distance,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14900 animation = {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14901
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14902 // Adjust
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14903 $.effects.save( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14904 el.show();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14905 distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14906
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14907 $.effects.createWrapper( el ).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14908 overflow: "hidden"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14909 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14910
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14911 if ( show ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14912 el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14913 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14914
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14915 // Animation
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14916 animation[ ref ] = ( show ?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14917 ( positiveMotion ? "+=" : "-=") :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14918 ( positiveMotion ? "-=" : "+=")) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14919 distance;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14920
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14921 // Animate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14922 el.animate( animation, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14923 queue: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14924 duration: o.duration,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14925 easing: o.easing,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14926 complete: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14927 if ( mode === "hide" ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14928 el.hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14929 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14930 $.effects.restore( el, props );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14931 $.effects.removeWrapper( el );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14932 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14933 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14934 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14935 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14936
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14937 })(jQuery);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14938 (function( $, undefined ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14939
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14940 $.effects.effect.transfer = function( o, done ) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14941 var elem = $( this ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14942 target = $( o.to ),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14943 targetFixed = target.css( "position" ) === "fixed",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14944 body = $("body"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14945 fixTop = targetFixed ? body.scrollTop() : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14946 fixLeft = targetFixed ? body.scrollLeft() : 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14947 endPosition = target.offset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14948 animation = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14949 top: endPosition.top - fixTop ,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14950 left: endPosition.left - fixLeft ,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14951 height: target.innerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14952 width: target.innerWidth()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14953 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14954 startPosition = elem.offset(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14955 transfer = $( "<div class='ui-effects-transfer'></div>" )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14956 .appendTo( document.body )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14957 .addClass( o.className )
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14958 .css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14959 top: startPosition.top - fixTop ,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14960 left: startPosition.left - fixLeft ,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14961 height: elem.innerHeight(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14962 width: elem.innerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14963 position: targetFixed ? "fixed" : "absolute"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14964 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14965 .animate( animation, o.duration, o.easing, function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14966 transfer.remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14967 done();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14968 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14969 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14970
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14971 })(jQuery);

mercurial