|
67 | 67 | case "left":
|
68 | 68 | right = ~~(docOuterWidth - elementLeft + options.offset);
|
69 | 69 | if (right + boxWidth + options.offset > docOuterWidth) {
|
70 |
| - right = 0; |
| 70 | + right = undefined; |
71 | 71 | left = ~~(elementLeft + elementOuterWidth + options.offset);
|
72 | 72 | }
|
73 | 73 | if (options.align === "top") {
|
|
88 | 88 | case "right":
|
89 | 89 | left = elementLeft + elementOuterWidth + options.offset;
|
90 | 90 | if (left + boxWidth + options.offset > docOuterWidth) {
|
91 |
| - left = 0; |
| 91 | + left = undefined; |
92 | 92 | right = docOuterWidth - elementLeft + options.offset;
|
93 | 93 | }
|
94 | 94 | if (options.align === "top") {
|
|
223 | 223 | return promisesArr;
|
224 | 224 | }
|
225 | 225 |
|
226 |
| - function PBoxModal(options, $target) { |
| 226 | + function BoxModal(options, $target) { |
227 | 227 | var _resultDeferred = $q.defer();
|
228 | 228 | var _openedDeferred = $q.defer();
|
229 | 229 | var _self = this;
|
|
238 | 238 |
|
239 | 239 | $target.data(globalOptions.boxInstanceName, this);
|
240 | 240 |
|
241 |
| - PBoxModal.prototype._remove = function () { |
| 241 | + BoxModal.prototype._remove = function () { |
242 | 242 | _self._$target.removeData(globalOptions.boxInstanceName);
|
243 | 243 | _self._$target.removeClass(this._options.openClass);
|
244 | 244 | _self._pboxElement.remove();
|
245 | 245 | };
|
246 | 246 |
|
247 |
| - PBoxModal.prototype._bindEvents = function () { |
| 247 | + BoxModal.prototype._bindEvents = function () { |
248 | 248 | $document.bind("mousedown.pbox", function (e) {
|
249 | 249 | var _eTarget = angular.element(e.target);
|
250 | 250 | if (util.hasClass(_eTarget, 'pbox')) {
|
|
268 | 268 | });
|
269 | 269 | };
|
270 | 270 |
|
271 |
| - PBoxModal.prototype.open = function (tpl, scope) { |
| 271 | + BoxModal.prototype.open = function (tpl, scope) { |
272 | 272 | _self._pboxElement = angular.element('<div class="pbox"></div>');
|
273 | 273 | _self._pboxElement.html(tpl);
|
274 | 274 | _self._$target.addClass(_self._options.openClass);
|
|
280 | 280 | _self._bindEvents();
|
281 | 281 | };
|
282 | 282 |
|
283 |
| - PBoxModal.prototype.close = function (result) { |
| 283 | + BoxModal.prototype.close = function (result) { |
284 | 284 | _self._remove();
|
285 | 285 | _resultDeferred.resolve(result);
|
286 | 286 | };
|
287 | 287 |
|
288 |
| - PBoxModal.prototype.dismiss = function (reason) { |
| 288 | + BoxModal.prototype.dismiss = function (reason) { |
289 | 289 | _self._remove();
|
290 | 290 | _resultDeferred.reject(reason);
|
291 | 291 | }
|
|
310 | 310 | options.placement = $target.data("placement") ? $target.data("placement") : options.placement;
|
311 | 311 | options.align = $target.data("align") ? $target.data("align") : options.align;
|
312 | 312 | if ($target.data(globalOptions.boxInstanceName)) {
|
313 |
| - return $target.data(globalOptions.boxInstanceName).close(); |
| 313 | + $target.data(globalOptions.boxInstanceName).close(); |
| 314 | + //fix click error when user result.then(); |
| 315 | + return {result: $q.defer().promise}; |
314 | 316 | }
|
315 | 317 |
|
316 |
| - var pboxInstance = new PBoxModal(options, $target); |
| 318 | + var pboxInstance = new BoxModal(options, $target); |
317 | 319 |
|
318 | 320 | var templateAndResolvePromise =
|
319 | 321 | $q.all([getTemplatePromise(options)].concat(getResolvePromises(options.resolve)));
|
320 | 322 |
|
321 | 323 | templateAndResolvePromise.then(function resolveSuccess(tplAndVars) {
|
322 | 324 |
|
323 |
| - var pboxScope = (options.scope || $rootScope).$new(); |
324 |
| - pboxScope.$close = pboxInstance.close; |
325 |
| - pboxScope.$dismiss = pboxInstance.dismiss; |
| 325 | + var boxScope = (options.scope || $rootScope).$new(); |
| 326 | + boxScope.$close = pboxInstance.close; |
| 327 | + boxScope.$dismiss = pboxInstance.dismiss; |
326 | 328 |
|
327 | 329 | var ctrlInstance, ctrlLocals = {};
|
328 | 330 | var resolveIter = 1;
|
329 | 331 |
|
330 | 332 | //controllers
|
331 | 333 | if (options.controller) {
|
332 |
| - ctrlLocals.$scope = pboxScope; |
| 334 | + ctrlLocals.$scope = boxScope; |
333 | 335 | ctrlLocals.$pboxInstance = pboxInstance;
|
334 |
| - pboxScope.$pboxInstance = pboxInstance; |
| 336 | + boxScope.$pboxInstance = pboxInstance; |
335 | 337 | angular.forEach(options.resolve, function (value, key) {
|
336 | 338 | ctrlLocals[key] = tplAndVars[resolveIter++];
|
337 | 339 | });
|
338 | 340 |
|
339 | 341 | ctrlInstance = $controller(options.controller, ctrlLocals);
|
340 | 342 | pboxInstance.ctrlInstance = ctrlInstance;
|
341 | 343 | if (options.controllerAs) {
|
342 |
| - pboxScope[options.controllerAs] = ctrlInstance; |
| 344 | + boxScope[options.controllerAs] = ctrlInstance; |
343 | 345 | }
|
344 | 346 | }
|
345 | 347 |
|
346 |
| - pboxInstance.open(tplAndVars[0], pboxScope); |
| 348 | + pboxInstance.open(tplAndVars[0], boxScope); |
347 | 349 |
|
348 | 350 | }, function resolveError(reason) {
|
349 | 351 | pboxInstance.resultDeferred.reject(reason);
|
|
0 commit comments