|
63 | 63 | photoScaled: false, // whether to scale the photo the scale of (options.width, options.height)
|
64 | 64 | photoFade: 500, // whether to use fade transition to show photos, false, or a miniseconds
|
65 | 65 |
|
| 66 | + padding: 0, // the padding of the content |
| 67 | + |
66 | 68 | imgError: 'Failed to load image.', // the error message when loading image
|
67 | 69 | xhrError: 'Failed to load URL.', // the error message when using ajax
|
68 | 70 | // these will be overrided by $.msgboxI18N.en.imgError
|
|
366 | 368 |
|
367 | 369 | // content
|
368 | 370 | this.$content = createElement('div', this.options.prefix + '-content', {
|
369 |
| - overflow: $.inArray(this.options.type, ['photo', 'image', 'album', 'gallery']) == -1 ? 'auto' : 'hidden', |
| 371 | + overflow: 'hidden', |
370 | 372 | position: 'relative'
|
371 | 373 | });
|
372 | 374 |
|
373 | 375 | // prompt
|
374 |
| - this.$prompt = createElement('input', this.options.prefix + '-prompt', {}, { |
| 376 | + this.$prompt = createElement('input', this.options.prefix + '-prompt-input', {}, { |
375 | 377 | type: 'text'
|
376 | 378 | });
|
| 379 | + |
| 380 | + this.$loaded = createElement('div', this.options.prefix + '-loaded', { |
| 381 | + padding: this.options.padding, |
| 382 | + width: '100%', |
| 383 | + height: '100%', |
| 384 | + overflow: $.inArray(this.options.type, ['photo', 'image', 'album', 'gallery']) == -1 ? 'auto' : 'hidden' |
| 385 | + }); |
| 386 | + |
| 387 | + this.$loading = createElement('div', this.options.prefix + '-loading', { |
| 388 | + height: '100%', |
| 389 | + width: '100%' |
| 390 | + }); |
377 | 391 | },
|
378 | 392 |
|
379 | 393 | // append the element to DOM
|
380 | 394 | _append: function () {
|
381 | 395 | if (this.options.overlay) $(document.body).append(this.$overlay);
|
382 |
| - $(document.body).append(this.$wrap.append(this.$title.append(this.$controls), this.$content)); |
| 396 | + $(document.body).append(this.$wrap.append(this.$title.append(this.$controls), this.$content.append(this.$loaded))); |
383 | 397 | if (this.options.buttons !== null && this.options.buttons.length > 0) {
|
384 | 398 | this.$foot.appendTo(this.$wrap);
|
385 | 399 | if (this.options.resize) this.$resize.appendTo(this.$foot);
|
386 | 400 | } else {
|
387 | 401 | if (this.options.resize) this.$resize.appendTo(this.$content);
|
388 |
| - } |
| 402 | + } |
389 | 403 | },
|
390 | 404 |
|
391 | 405 | _bindEvents: function () {
|
|
527 | 541 |
|
528 | 542 | var that = this;
|
529 | 543 | // purge
|
530 |
| - this.$content.contents().filter(function(){ |
531 |
| - return this.nodeType == 3 || (!$(this).is(that.$img) && !$(this).is(that.$resize)); |
532 |
| - }).remove(); |
| 544 | + //this.$content.contents().filter(function(){ |
| 545 | + // return this.nodeType == 3 || (!$(this).is(that.$img) && !$(this).is(that.$resize)); |
| 546 | + //}).remove(); |
533 | 547 |
|
534 | 548 | this.$loading = createElement('div', this.options.prefix + '-loading', {
|
535 | 549 | height: '100%',
|
536 | 550 | width: '100%'
|
537 |
| - }).appendTo(this.$content); |
| 551 | + }).appendTo(this.$loaded); |
538 | 552 |
|
539 | 553 | if (!this.titleSpecified) this.title ($handler.attr('title'));
|
540 | 554 |
|
|
585 | 599 | that.$img.attr(val, attr);
|
586 | 600 | });
|
587 | 601 |
|
588 |
| - this.$img.hide().appendTo(this.$content) |
| 602 | + this.$img.hide().appendTo(this.$loaded) |
589 | 603 | .error(function(){
|
590 | 604 | that.$loading.remove();
|
591 | 605 | that.$loading = undefined;
|
|
604 | 618 |
|
605 | 619 | _load: function (callback) {
|
606 | 620 | if (this.loaded) return;
|
607 |
| - this.$loaded = createElement('div', this.options.prefix + '-loaded'); |
| 621 | + |
608 | 622 |
|
609 | 623 | switch (this.options.type) {
|
610 | 624 | case 'text':
|
611 |
| - this.$loaded.text(this.options.content).appendTo(this.$content); |
| 625 | + this.$loaded.text(this.options.content); |
612 | 626 | this.loaded = true;
|
613 | 627 | if (callback) callback.apply(this);
|
614 | 628 | if (this.options.onLoad) this.options.onLoad.apply(this);
|
615 | 629 | break;
|
616 | 630 |
|
617 | 631 | case 'html':
|
618 |
| - case 'confirm': |
619 |
| - var content = $.type(this.options.content)==='object' ? this.options.content.show() : this.options.content; |
620 |
| - this.$loaded.html(content).appendTo(this.$content); |
| 632 | + var content = $.type(this.options.content)==='object' |
| 633 | + ? this.options.content.show() |
| 634 | + : this.options.content; |
| 635 | + |
| 636 | + this.$loaded.append(content); |
621 | 637 | this.loaded = true;
|
622 | 638 | if (callback) callback.apply(this);
|
623 | 639 | if (this.options.onLoad) this.options.onLoad.apply(this);
|
|
628 | 644 | case 'info':
|
629 | 645 | case 'error':
|
630 | 646 | case 'success':
|
631 |
| - this.$loaded.html(this.options.content).appendTo(this.$content.addClass(this.options.prefix + '-' + this.options.type)); |
| 647 | + case 'confirm': |
| 648 | + var content = $.type(this.options.content)==='object' |
| 649 | + ? this.options.content.show() |
| 650 | + : this.options.content; |
| 651 | + |
| 652 | + this.$loaded.append(content).addClass( |
| 653 | + this.options.prefix + '-shortcut ' |
| 654 | + + this.options.prefix + '-' + this.options.type); |
632 | 655 | this.loaded = true;
|
633 | 656 | if (callback) callback.apply(this);
|
634 | 657 | if (this.options.onLoad) this.options.onLoad.apply(this);
|
635 | 658 | break;
|
636 | 659 |
|
637 | 660 | case 'prompt':
|
638 |
| - this.$loaded.html(this.options.content) |
639 |
| - .append(this.$prompt) |
640 |
| - .appendTo(this.$content); |
| 661 | + var content = $.type(this.options.content)==='object' |
| 662 | + ? this.options.content.show() |
| 663 | + : this.options.content; |
| 664 | + |
| 665 | + this.$loaded.append(content).append(this.$prompt).addClass( |
| 666 | + this.options.prefix + '-shortcut ' |
| 667 | + + this.options.prefix + '-' + this.options.type); |
| 668 | + |
641 | 669 | this.loaded = true;
|
642 | 670 | if (callback) callback.apply(this);
|
643 | 671 | if (this.options.onLoad) this.options.onLoad.apply(this);
|
|
708 | 736 | marginwidth: '0px',
|
709 | 737 | scrolling: 'auto',
|
710 | 738 | src: this.options.content
|
711 |
| - }).appendTo(that.$content).one('load', function() { |
| 739 | + }).appendTo(that.$loaded).one('load', function() { |
712 | 740 | $loading.remove();
|
713 | 741 | that.$iframe.show();
|
714 | 742 | if (!that.options.title) {
|
|
1037 | 1065 | };
|
1038 | 1066 | }
|
1039 | 1067 |
|
1040 |
| - if (this.options.onOpen) this.options.onOpen.apply(this); |
1041 |
| - |
1042 | 1068 |
|
1043 | 1069 | var that = this;
|
1044 | 1070 | var rightAfterOpen = function () {
|
1045 | 1071 | that.opened = true;
|
1046 | 1072 | $.msgbox._focused = that;
|
| 1073 | + if (that.options.onOpen) that.options.onOpen.apply(that); |
1047 | 1074 | if (callback) callback.apply(that);
|
1048 | 1075 | };
|
1049 | 1076 | var mayPlayAlbum = function () {
|
|
1244 | 1271 | content: function (ctt) {
|
1245 | 1272 | var that = this;
|
1246 | 1273 | if (ctt === undefined) {
|
1247 |
| - return this.$content.has(this.$loaded).length |
1248 |
| - ? this.$loaded.html() |
1249 |
| - : this.$content.contents().filter(function(){ |
1250 |
| - return !$(this).is(that.$resize); |
1251 |
| - }).html(); |
| 1274 | + return this.$loaded.html(); |
1252 | 1275 | } else {
|
1253 |
| - if (this.$content.has(this.$loaded).length) { |
1254 |
| - this.$loaded.html(ctt); |
1255 |
| - } else { |
1256 |
| - this.$content.contents().filter(function(){ |
1257 |
| - return !$(this).is(that.$resize) && !$(this).is(that.$img); |
1258 |
| - }).remove(); |
1259 |
| - this.$content.prepend(ctt); |
1260 |
| - } |
| 1276 | + this.$loaded.html(ctt); |
1261 | 1277 | }
|
1262 | 1278 | return true;
|
1263 | 1279 | }
|
|
0 commit comments