Changeset 5388
- Timestamp:
- 05/02/08 21:16:57 (8 months ago)
- Files:
-
- 1 modified
-
trunk/ui/ui.base.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/ui.base.js
r5373 r5388 62 62 } 63 63 }, 64 call: function(instance, name, arguments) { 65 var set = instance.plugins[name]; if(!set) return; 64 call: function(instance, name, args) { 65 var set = instance.plugins[name]; 66 if(!set) { return; } 67 66 68 for (var i = 0; i < set.length; i++) { 67 if (instance.options[set[i][0]]) set[i][1].apply(instance.element, arguments); 69 if (instance.options[set[i][0]]) { 70 set[i][1].apply(instance.element, args); 71 } 68 72 } 69 73 } … … 71 75 cssCache: {}, 72 76 css: function(name) { 73 if ($.ui.cssCache[name]) return $.ui.cssCache[name];77 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } 74 78 var tmp = $('<div class="ui-resizable-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); 75 79 … … 80 84 //Safari returns rgba(0,0,0,0) when bgcolor is not set 81 85 $.ui.cssCache[name] = !!( 82 (! /auto|default/.test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||86 (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || 83 87 !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))) 84 88 ); … … 88 92 disableSelection: function(e) { 89 93 e.unselectable = "on"; 90 e.onselectstart = function() { return false; };91 if (e.style) e.style.MozUserSelect = "none";94 e.onselectstart = function() { return false; }; 95 if (e.style) { e.style.MozUserSelect = "none"; } 92 96 }, 93 97 enableSelection: function(e) { 94 98 e.unselectable = "off"; 95 99 e.onselectstart = function() { return true; }; 96 if (e.style) e.style.MozUserSelect = "";100 if (e.style) { e.style.MozUserSelect = ""; } 97 101 }, 98 102 hasScroll: function(e, a) { … … 115 119 removeMouseInteraction: function(o) { 116 120 return this.each(function() { 117 if($.data(this, "ui-mouse")) 121 if($.data(this, "ui-mouse")) { 118 122 $.data(this, "ui-mouse").destroy(); 123 } 119 124 }); 120 125 }, … … 137 142 138 143 $(element).bind('mousedown.draggable', function() { return self.click.apply(self, arguments); }); 139 if($.browser.msie) $(element).attr('unselectable', 'on'); //Prevent text selection in IE 144 if($.browser.msie) { 145 //Prevent text selection in IE 146 $(element).attr('unselectable', 'on'); 147 } 140 148 141 149 // prevent draggable-options-delay bug #2553 142 150 $(element).mouseup(function() { 143 if(self.timer) clearInterval(self.timer);151 if(self.timer) { clearInterval(self.timer); } 144 152 }); 145 153 }; … … 155 163 || $.inArray(e.target.nodeName.toLowerCase(), this.options.dragPrevention || []) != -1 // Prevent execution on defined elements 156 164 || (this.options.condition && !this.options.condition.apply(this.options.executor || this, [e, this.element])) //Prevent execution on condition 157 ) return true;165 ) { return true; } 158 166 159 167 var self = this; … … 164 172 165 173 if(!self.initalized && Math.abs(self._MP.left-e.pageX) >= self.options.distance || Math.abs(self._MP.top-e.pageY) >= self.options.distance) { 166 if(self.options.start) self.options.start.call(self.options.executor || self, e, self.element); 167 if(self.options.drag) self.options.drag.call(self.options.executor || self, e, this.element); //This is actually not correct, but expected 174 if(self.options.start) { 175 self.options.start.call(self.options.executor || self, e, self.element); 176 } 177 if(self.options.drag) { 178 //This is actually not correct, but expected 179 self.options.drag.call(self.options.executor || self, e, this.element); 180 } 168 181 self.initialized = true; 169 182 } … … 171 184 172 185 if(this.options.delay) { 173 if(this.timer) clearInterval(this.timer);186 if(this.timer) { clearInterval(this.timer); } 174 187 this.timer = setTimeout(initialize, this.options.delay); 175 188 } else { … … 183 196 184 197 var o = this.options; 185 if(!this.initialized) return $(document).unbind('mouseup.draggable').unbind('mousemove.draggable'); 186 187 if(this.options.stop) this.options.stop.call(this.options.executor || this, e, this.element); 198 if(!this.initialized) { 199 return $(document) 200 .unbind('mouseup.draggable') 201 .unbind('mousemove.draggable'); 202 } 203 204 if(this.options.stop) { 205 this.options.stop.call(this.options.executor || this, e, this.element); 206 } 188 207 $(document).unbind('mouseup.draggable').unbind('mousemove.draggable'); 189 208 this.initialized = false; … … 194 213 195 214 var o = this.options; 196 if ($.browser.msie && !e.button) return this.stop.apply(this, [e]); // IE mouseup check 215 if ($.browser.msie && !e.button) { 216 // IE mouseup check 217 return this.stop.apply(this, [e]); 218 } 197 219 198 220 if(!this.initialized && (Math.abs(this._MP.left-e.pageX) >= o.distance || Math.abs(this._MP.top-e.pageY) >= o.distance)) { 199 if(this.options.start) this.options.start.call(this.options.executor || this, e, this.element); 221 if(this.options.start) { 222 this.options.start.call(this.options.executor || this, e, this.element); 223 } 200 224 this.initialized = true; 201 225 } else { 202 if(!this.initialized) return false; 203 } 204 205 if(o.drag) o.drag.call(this.options.executor || this, e, this.element); 226 if(!this.initialized) { return false; } 227 } 228 229 if(o.drag) { 230 o.drag.call(this.options.executor || this, e, this.element); 231 } 206 232 return false; 207 233
