|
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") |
|
239 | 239 | } |
240 | 240 |
|
241 | 241 | function BoxModal(options, $target) { |
242 | | - var _resultDeferred = $q.defer(); |
243 | | - var _openedDeferred = $q.defer(); |
244 | | - var _self = this; |
245 | 242 | this._id = new Date().getTime() + Math.random().toString(36).substr(2); |
246 | | - this.resultDeferred = _resultDeferred; |
247 | | - this.openedDeferred = _openedDeferred; |
248 | | - this.result = _resultDeferred.promise; |
249 | | - this.opened = _openedDeferred.promise; |
| 243 | + this.resultDeferred = $q.defer(); |
| 244 | + this.openedDeferred = $q.defer(); |
| 245 | + this.result = this.resultDeferred.promise; |
| 246 | + this.opened = this.openedDeferred.promise; |
250 | 247 | this._options = options; |
251 | 248 | this._pboxElement = null; |
252 | 249 | this._$target = $target; |
253 | | - $target.data(globalOptions.boxInstanceName, _self); |
| 250 | + $target.data(globalOptions.boxInstanceName, this); |
254 | 251 |
|
255 | 252 | BoxModal.prototype._remove = function () { |
256 | 253 | this._$target.removeData(globalOptions.boxInstanceName); |
|
259 | 256 | }; |
260 | 257 |
|
261 | 258 | BoxModal.prototype._bindEvents = function () { |
| 259 | + var _self = this; |
262 | 260 | if (_self._options.autoClose) { |
263 | 261 | _self._pboxElement.bind("mousedown.pbox", function (e) { |
264 | 262 | e.stopPropagation(); |
|
297 | 295 | }; |
298 | 296 |
|
299 | 297 | BoxModal.prototype.open = function (tpl, scope) { |
| 298 | + var _self = this; |
300 | 299 | this._pboxElement = angular.element('<div class="pbox"></div>'); |
301 | 300 | this._pboxElement.html(tpl); |
302 | 301 | this._$target.addClass(this._options.openClass); |
|
0 commit comments