|
150 | 150 | .provider("$pbox", [function () { |
151 | 151 | // The default options for all popboxs. |
152 | 152 | var defaultOptions = { |
153 | | - placement: 'bottom', |
154 | | - align: null, //居什么对齐 left,right,bottom,top |
155 | | - animation: false,//是否有动画 |
156 | | - delay: 0, //延迟多长时间弹出 |
157 | | - arrow: false, |
158 | | - openClass: 'pbox-open', |
| 153 | + placement : 'bottom', |
| 154 | + align : null, //居什么对齐 left,right,bottom,top |
| 155 | + animation : false,//是否有动画 |
| 156 | + delay : 0, //延迟多长时间弹出 |
| 157 | + arrow : false, |
| 158 | + openClass : 'pbox-open', |
159 | 159 | closeClass: 'pbox-close', |
160 | | - autoClose: true, //点击其他区域自动关闭,当点击触发弹出框的元素或者弹出框内部元素时不关闭, |
| 160 | + autoClose : true, //点击其他区域自动关闭,当点击触发弹出框的元素或者弹出框内部元素时不关闭, |
161 | 161 | forceClose: false,//autoClose为true时起作用,点击触发弹出框的元素也关闭 |
162 | | - offset: 1, //位移位置 |
163 | | - autoAdapt: true, //是否自动计算上下,左右的高度或者宽度,当 placement 为 bottom,top的时候为true,自动调整 placement |
164 | | - watch: false,//watch 弹出框的宽高,当有变化的时候重新计算位置 |
165 | | - resolve: {} |
| 162 | + offset : 1, //位移位置 |
| 163 | + autoAdapt : true, //是否自动计算上下,左右的高度或者宽度,当 placement 为 bottom,top的时候为true,自动调整 placement |
| 164 | + watch : false,//watch 弹出框的宽高,当有变化的时候重新计算位置 |
| 165 | + resolve : {} |
166 | 166 | }; |
167 | 167 |
|
168 | 168 | var globalOptions = { |
169 | | - triggerClass: "pbox-trigger", |
| 169 | + triggerClass : "pbox-trigger", |
170 | 170 | boxInstanceName: "boxInstance" |
171 | 171 | }; |
172 | 172 |
|
|
175 | 175 | }; |
176 | 176 |
|
177 | 177 | var util = { |
178 | | - hasClass: function (element, className) { |
| 178 | + hasClass : function (element, className) { |
179 | 179 | return element.hasClass(className) || element.parents("." + className).length > 0; |
180 | 180 | }, |
181 | 181 | hasClasses: function (element, classes) { |
|
188 | 188 | }); |
189 | 189 | return result; |
190 | 190 | }, |
191 | | - getTarget: function (event) { |
| 191 | + getTarget : function (event) { |
192 | 192 | var $target = angular.element(event.target); |
193 | 193 | if (!$target) { |
194 | 194 | throw new Error("The event") |
|
283 | 283 | } |
284 | 284 | _self.close(); |
285 | 285 | }); |
| 286 | + |
| 287 | + _self._pboxElement.bind("keydown.pbox", function (e) { |
| 288 | + e.stopPropagation(); |
| 289 | + }); |
| 290 | + $document.bind("keydown.pbox" + _self._id, function (evt) { |
| 291 | + if (evt.which == 27) { |
| 292 | + evt.preventDefault(); |
| 293 | + _self.close(); |
| 294 | + } |
| 295 | + }); |
286 | 296 | } |
287 | 297 | }; |
288 | 298 |
|
|
315 | 325 | this._scope && this._scope.$destroy(); |
316 | 326 | this._scope = null; |
317 | 327 | $document.unbind("mousedown.pbox" + this._id); |
| 328 | + $document.unbind("keydown.pbox" + this._id); |
318 | 329 | _resultDeferred.resolve(result); |
319 | 330 | }; |
320 | 331 |
|
321 | 332 | BoxModal.prototype.dismiss = function (reason) { |
322 | 333 | this._remove(); |
| 334 | + this.$watch && this.$watch(); |
323 | 335 | this._scope && this._scope.$destroy(); |
324 | 336 | this._scope = null; |
| 337 | + $document.unbind("mousedown.pbox" + this._id); |
| 338 | + $document.unbind("keydown.pbox" + this._id); |
325 | 339 | _resultDeferred.reject(reason); |
326 | 340 | } |
327 | 341 | } |
|
0 commit comments