zui.lite.js 84.8 KB
Newer Older
C
Catouse 已提交
1
/*!
C
Catouse 已提交
2
 * ZUI - v1.2.0-beta - 2014-10-24
C
Catouse 已提交
3
 * http://zui.sexy
C
Catouse 已提交
4
 * GitHub: https://github.com/easysoft/zui.git 
C
Catouse 已提交
5
 * Copyright (c) 2014 cnezsoft.com; Licensed MIT
C
Catouse 已提交
6 7 8 9
 */

/* Some code copy from Bootstrap v3.0.0 by @fat and @mdo. (Copyright 2013 Twitter, Inc. Licensed under http://www.apache.org/licenses/)*/

C
Catouse 已提交
10 11
/* $ComponentName$ */
+function($, window, document, Math)
C
Catouse 已提交
12 13 14
{
    "use strict";

C
Catouse 已提交
15
    $.extend(
C
Catouse 已提交
16
    {
C
Catouse 已提交
17 18 19 20 21 22 23 24 25
        uuid: function()
        {
            var d = (new Date).getTime();
            while(d < 10000000000000000)
            {
               d *= 10;
            }
            return  d + Math.floor(Math.random() * 9999);
        },
26

C
Catouse 已提交
27
        getPropertyCount: function(obj)
28
        {
C
Catouse 已提交
29 30 31 32 33
           if(typeof(obj) != 'object' || obj == null) return 0;
           return Object.getOwnPropertyNames(obj).length;
        },

        callEvent: function(func, event, proxy)
34
        {
C
Catouse 已提交
35
            if($.isFunction(func))
36
            {
C
Catouse 已提交
37 38 39 40 41 42
                if(typeof proxy != 'undefined')
                {
                    func = $.proxy(func, proxy);
                }
                event.result = func(event);
                return !(event.result != undefined && (!event.result));
43
            }
C
Catouse 已提交
44 45
            return 1;
        },
46

C
Catouse 已提交
47
        clientLang: function()
48
        {
C
Catouse 已提交
49 50 51 52 53 54 55 56 57 58 59
            var lang;
            if(typeof(window.config) != 'undefined' && window.config.clientLang)
            {
                lang = window.config.clientLang;
            }
            else
            {
                var hl = $('html').attr('lang');
                lang = hl ? hl : (navigator.userLanguage || navigator.userLanguage || 'zh_cn');
            }
            return lang.replace('-', '_').toLowerCase();
60
        }
C
Catouse 已提交
61
    });
62

C
Catouse 已提交
63
    $.fn.callEvent = function(name, event, model)
64
    {
C
Catouse 已提交
65 66 67 68
        var $this = $(this);
        var dotIndex = name.indexOf('.zui.');
        var shortName = name;
        if(dotIndex < 0 && model && model.name)
69
        {
C
Catouse 已提交
70
            name += '.' + model.name;
71 72 73
        }
        else
        {
C
Catouse 已提交
74
            shortName = name.substring(0, dotIndex);
75
        }
C
Catouse 已提交
76
        var e     = $.Event(name, event);
C
Catouse 已提交
77

C
Catouse 已提交
78 79 80
        var result = $this.trigger(e);

        if((typeof model === 'undefined') && dotIndex > 0)
C
Catouse 已提交
81
        {
C
Catouse 已提交
82
            model = $this.data(name.substring(dotIndex + 1));
C
Catouse 已提交
83 84
        }

C
Catouse 已提交
85
        if(model && model.options)
C
Catouse 已提交
86
        {
C
Catouse 已提交
87 88 89 90 91
            var func = model.options[shortName];
            if($.isFunction(func))
            {
                $.callEvent(model.options[shortName], e, model);
            }
C
Catouse 已提交
92
        }
C
Catouse 已提交
93
        return e;
C
Catouse 已提交
94
    };
C
Catouse 已提交
95
}(jQuery,window,document,Math);
C
Catouse 已提交
96

C
Catouse 已提交
97 98 99 100 101 102 103
/* ========================================================================
 * Bootstrap: transition.js v3.2.0
 * http://getbootstrap.com/javascript/#transitions
 * ========================================================================
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */
C
Catouse 已提交
104 105


C
Catouse 已提交
106 107
+function ($) {
  'use strict';
C
Catouse 已提交
108

C
Catouse 已提交
109 110
  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================
C
Catouse 已提交
111

C
Catouse 已提交
112 113
  function transitionEnd() {
    var el = document.createElement('bootstrap')
C
Catouse 已提交
114

C
Catouse 已提交
115 116 117 118 119 120
    var transEndEventNames = {
      WebkitTransition : 'webkitTransitionEnd',
      MozTransition    : 'transitionend',
      OTransition      : 'oTransitionEnd otransitionend',
      transition       : 'transitionend'
    }
C
Catouse 已提交
121

C
Catouse 已提交
122 123 124 125 126
    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
        return { end: transEndEventNames[name] }
      }
    }
C
Catouse 已提交
127

C
Catouse 已提交
128 129
    return false // explicit for ie8 (  ._.)
  }
C
Catouse 已提交
130

C
Catouse 已提交
131 132 133 134 135 136 137 138 139
  // http://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
    var called = false
    var $el = this
    $(this).one('bsTransitionEnd', function () { called = true })
    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
    setTimeout(callback, duration)
    return this
  }
C
Catouse 已提交
140

C
Catouse 已提交
141 142
  $(function () {
    $.support.transition = transitionEnd()
C
Catouse 已提交
143

C
Catouse 已提交
144
    if (!$.support.transition) return
C
Catouse 已提交
145

C
Catouse 已提交
146 147 148 149 150 151 152 153
    $.event.special.bsTransitionEnd = {
      bindType: $.support.transition.end,
      delegateType: $.support.transition.end,
      handle: function (e) {
        if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
      }
    }
  })
C
Catouse 已提交
154

C
Catouse 已提交
155
}(jQuery);
C
Catouse 已提交
156

C
Catouse 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
/* ========================================================================
 * Bootstrap: collapse.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#collapse
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */
C
Catouse 已提交
175

C
Catouse 已提交
176

C
Catouse 已提交
177
+function ($) { "use strict";
C
Catouse 已提交
178

C
Catouse 已提交
179 180
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
C
Catouse 已提交
181

C
Catouse 已提交
182 183 184 185
  var Collapse = function (element, options) {
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.transitioning = null
C
Catouse 已提交
186

C
Catouse 已提交
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
    if (this.options.parent) this.$parent = $(this.options.parent)
    if (this.options.toggle) this.toggle()
  }

  Collapse.DEFAULTS = {
    toggle: true
  }

  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
  }

  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return

    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

    var actives = this.$parent && this.$parent.find('> .panel > .in')

    if (actives && actives.length) {
      var hasData = actives.data('bs.collapse')
      if (hasData && hasData.transitioning) return
      actives.collapse('hide')
      hasData || actives.data('bs.collapse', null)
C
Catouse 已提交
214 215
    }

C
Catouse 已提交
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    var dimension = this.dimension()

    this.$element
      .removeClass('collapse')
      .addClass('collapsing')
      [dimension](0)

    this.transitioning = 1

    var complete = function () {
      this.$element
        .removeClass('collapsing')
        .addClass('in')
        [dimension]('auto')
      this.transitioning = 0
      this.$element.trigger('shown.bs.collapse')
C
Catouse 已提交
232 233
    }

C
Catouse 已提交
234
    if (!$.support.transition) return complete.call(this)
C
Catouse 已提交
235

C
Catouse 已提交
236
    var scrollSize = $.camelCase(['scroll', dimension].join('-'))
C
Catouse 已提交
237

C
Catouse 已提交
238 239 240 241 242
    this.$element
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
      [dimension](this.$element[0][scrollSize])
  }
C
Catouse 已提交
243

C
Catouse 已提交
244 245
  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return
C
Catouse 已提交
246

C
Catouse 已提交
247 248 249
    var startEvent = $.Event('hide.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return
C
Catouse 已提交
250

C
Catouse 已提交
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
    var dimension = this.dimension()

    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight

    this.$element
      .addClass('collapsing')
      .removeClass('collapse')
      .removeClass('in')

    this.transitioning = 1

    var complete = function () {
      this.transitioning = 0
      this.$element
        .trigger('hidden.bs.collapse')
        .removeClass('collapsing')
        .addClass('collapse')
    }

    if (!$.support.transition) return complete.call(this)

    this.$element
      [dimension](0)
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
C
Catouse 已提交
278 279
  }

C
Catouse 已提交
280 281 282
  Collapse.prototype.toggle = function () {
    this[this.$element.hasClass('in') ? 'hide' : 'show']()
  }
C
Catouse 已提交
283 284


C
Catouse 已提交
285 286
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
C
Catouse 已提交
287

C
Catouse 已提交
288
  var old = $.fn.collapse
C
Catouse 已提交
289

C
Catouse 已提交
290 291 292 293 294
  $.fn.collapse = function (option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.collapse')
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
C
Catouse 已提交
295

C
Catouse 已提交
296 297 298 299
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }
C
Catouse 已提交
300

C
Catouse 已提交
301
  $.fn.collapse.Constructor = Collapse
C
Catouse 已提交
302 303


C
Catouse 已提交
304 305
  // COLLAPSE NO CONFLICT
  // ====================
C
Catouse 已提交
306

C
Catouse 已提交
307 308 309 310
  $.fn.collapse.noConflict = function () {
    $.fn.collapse = old
    return this
  }
311 312


C
Catouse 已提交
313 314
  // COLLAPSE DATA-API
  // =================
315

C
Catouse 已提交
316 317 318 319 320 321 322 323 324 325
  $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
    var $this   = $(this), href
    var target  = $this.attr('data-target')
        || e.preventDefault()
        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
    var $target = $(target)
    var data    = $target.data('bs.collapse')
    var option  = data ? 'toggle' : $this.data()
    var parent  = $this.attr('data-parent')
    var $parent = parent && $(parent)
326

C
Catouse 已提交
327 328 329 330 331 332 333 334 335
    if (!data || !data.transitioning) {
      if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
      $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
    }

    $target.collapse(option)
  })

}(window.jQuery);
C
Catouse 已提交
336 337

/* Device */
C
Catouse 已提交
338
+function($)
C
Catouse 已提交
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
{
    var desktopLg = 1200,
        desktop   = 992,
        tablet    = 768,
        cssNames  = {desktop: 'screen-desktop', desktopLg: 'screen-desktop-wide', tablet: 'screen-tablet', phone: 'screen-phone', isMobile: 'device-mobile', isDesktop: 'device-desktop'};

    var resetCssClass = function()
    {
        var width = $(window).width();
        $('html').toggleClass(cssNames.desktop, width >= desktop && width < desktopLg)
                 .toggleClass(cssNames.desktopLg, width >= desktopLg)
                 .toggleClass(cssNames.tablet, width >= tablet && width < desktop)
                 .toggleClass(cssNames.phone, width < tablet)
                 .toggleClass(cssNames.isMobile, width < desktop)
                 .toggleClass(cssNames.isDesktop, width >= desktop);
    };

    $(window).resize(resetCssClass);
    resetCssClass();
}(jQuery);
C
Catouse 已提交
359

C
Catouse 已提交
360 361 362 363 364 365 366 367 368 369
/* $ComponentName$ */
+function(window, $)
{
    "use strict";
    var browseHappyTip =
    {
        "zh_cn": '您的浏览器版本过低,无法体验所有功能,建议升级或者更换浏览器。 <a href="http://browsehappy.com/" target="_blank" class="alert-link">了解更多...</a>',
        "zh_tw": '您的瀏覽器版本過低,無法體驗所有功能,建議升級或者更换瀏覽器。<a href="http://browsehappy.com/" target="_blank" class="alert-link">了解更多...</a>',
        "en": 'Your browser is too old, it has been unable to experience the colorful internet. We strongly recommend that you upgrade a better one. <a href="http://browsehappy.com/" target="_blank" class="alert-link">Learn more...</a>'
    };
C
Catouse 已提交
370

C
Catouse 已提交
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
    // The $componentName$ modal class
    var Browser = function()
    {
        var isIE = this.isIE;
        var ie = isIE();
        if(ie)
        {
            for(var i = 10; i > 5; i--)
            {
                if(isIE(i))
                {
                    ie = i;
                    break;
                }
            }
        }
C
Catouse 已提交
387

C
Catouse 已提交
388
        this.ie = ie;
C
Catouse 已提交
389

C
Catouse 已提交
390 391
        this.cssHelper();
    };
C
Catouse 已提交
392

C
Catouse 已提交
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
    // Append CSS class to html tag
    Browser.prototype.cssHelper = function()
    {
        var ie = this.ie,
            $html = $('html');
        $html.toggleClass('ie', ie)
             .removeClass('ie-6 ie-7 ie-8 ie-9 ie-10 ie-11');
        if(ie)
        {
            $html.addClass('ie-' + ie)
                 .toggleClass('gt-ie-7 gte-ie-8 support-ie',ie >= 8)
                 .toggleClass('lte-ie-7 lt-ie-8 outdated-ie', ie < 8)
                 .toggleClass('gt-ie-8 gte-ie-9',ie >= 9)
                 .toggleClass('lte-ie-8 lt-ie-9', ie < 9)
                 .toggleClass('gt-ie-9 gte-ie-10',ie >= 10)
                 .toggleClass('lte-ie-9 lt-ie-10', ie < 10);
        }
    };
C
Catouse 已提交
411

C
Catouse 已提交
412 413 414 415 416 417 418 419 420 421 422
    // Show browse happy tip
    Browser.prototype.tip = function()
    {
        if(this.ie && this.ie < 8)
        {
            var $browseHappy = $('#browseHappyTip');
            if(!$browseHappy.length)
            {
                $browseHappy = $('<div id="browseHappyTip" class="alert alert-dismissable alert-danger alert-block" style="position: relative; z-index: 99999"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><div class="container"><div class="content text-center"></div></div></div>');
                $browseHappy.prependTo('body');
            }
C
Catouse 已提交
423

C
Catouse 已提交
424 425 426
            $browseHappy.find('.content').html(this.browseHappyTip || browseHappyTip[$.clientLang() || 'zh_cn']);
        }
    };
C
Catouse 已提交
427

C
Catouse 已提交
428 429 430 431 432 433 434 435
    // Detect it is IE, can given a version
    Browser.prototype.isIE = function(version)
    {
        // var ie = /*@cc_on !@*/false;
        var b = document.createElement('b');
        b.innerHTML = '<!--[if IE ' + (version || '') + ']><i></i><![endif]-->';
        return b.getElementsByTagName('i').length === 1;
    };
C
Catouse 已提交
436

C
Catouse 已提交
437 438 439 440 441
    // Detect ie 10 with hack
    Browser.prototype.isIE10 = function()
    {
        return (/*@cc_on!@*/false);
    };
C
Catouse 已提交
442

C
Catouse 已提交
443
    window.browser = new Browser();
C
Catouse 已提交
444

C
Catouse 已提交
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
    $(function()
    {
        if(!$('body').hasClass('disabled-browser-tip'))
        {
            window.browser.tip();
        }
    });
}(window, jQuery);

/**
 * Format date to a string
 *
 * @param  string   format
 * @return string
 */
Date.prototype.format = function(format)
{
    var date =
    {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S+": this.getMilliseconds()
    };
    if (/(y+)/i.test(format))
    {
        format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in date)
    {
        if (new RegExp("(" + k + ")").test(format))
        {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
        }
    }
    return format;
};
C
Catouse 已提交
485

C
Catouse 已提交
486 487 488 489 490
Date.prototype.addMilliseconds = function(value)
{
    this.setTime(this.getTime() + value);
    return this;
};
C
Catouse 已提交
491

C
Catouse 已提交
492 493 494 495 496
Date.prototype.addDays = function(days)
{
    this.addMilliseconds(days * 24 * 3600 * 1000);
    return this;
};
C
Catouse 已提交
497

C
Catouse 已提交
498 499 500 501 502 503
Date.prototype.clone = function()
{
    var date =new Date();
    date.setTime(this.getTime());
    return date;
};
C
Catouse 已提交
504

C
Catouse 已提交
505 506 507 508
Date.isLeapYear = function (year)
{
    return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
};
C
Catouse 已提交
509

C
Catouse 已提交
510 511 512 513
Date.getDaysInMonth = function (year, month)
{
    return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};
C
Catouse 已提交
514

C
Catouse 已提交
515 516 517 518 519
Date.prototype.isLeapYear = function ()
{
    var y = this.getFullYear();
    return (((y % 4 === 0) && (y % 100 !== 0)) || (y % 400 === 0));
};
C
Catouse 已提交
520

C
Catouse 已提交
521 522 523 524
Date.prototype.getDaysInMonth = function ()
{
    return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
};
C
Catouse 已提交
525

C
Catouse 已提交
526 527 528 529 530 531 532 533
Date.prototype.addMonths = function (value)
{
    var n = this.getDate();
    this.setDate(1);
    this.setMonth(this.getMonth() + value);
    this.setDate(Math.min(n, this.getDaysInMonth()));
    return this;
};
C
Catouse 已提交
534

C
Catouse 已提交
535 536 537 538
// Date.prototype.isSameDay = function(date)
// {
//     return date.toDateString() === this.toDateString();
// };
C
Catouse 已提交
539

C
Catouse 已提交
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
/**
 * Format string
 *  
 * @param  object|array args
 * @return string
 */
(function(){
String.prototype.format = function(args)
{
    var result = this;
    if (arguments.length > 0)
    {
        var reg;
        if (arguments.length == 1 && typeof(args) == "object")
        {
            for (var key in args)
            {
                if (args[key] != undefined)
                {
                    reg = new RegExp("({" + key + "})", "g");
                    result = result.replace(reg, args[key]);
                }
            }
        }
        else
        {
            for (var i = 0; i < arguments.length; i++)
            {
                if (arguments[i] != undefined)
                {
                    reg = new RegExp("({[" + i + "]})", "g");
                    result = result.replace(reg, arguments[i]);
                }
            }
        }
    }
    return result;
};
C
Catouse 已提交
578 579


C
Catouse 已提交
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
/**
 * Judge the string is a integer number
 * 
 * @access public
 * @return bool
 */
String.prototype.isNum = function(s)
{
    if(s!=null)
    {
        var r, re;
        re = /\d*/i;
        r = s.match(re);
        return (r == s) ? true : false;
    }
    return false;
}
})();
C
Catouse 已提交
598

C
Catouse 已提交
599 600 601 602 603 604 605 606
/*!
 * jQuery resize event - v1.1 - 3/14/2010
 * http://benalman.com/projects/jquery-resize-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
C
Catouse 已提交
607

C
Catouse 已提交
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
// Script: jQuery resize event
//
// *Version: 1.1, Last updated: 3/14/2010*
// 
// Project Home - http://benalman.com/projects/jquery-resize-plugin/
// GitHub       - http://github.com/cowboy/jquery-resize/
// Source       - http://github.com/cowboy/jquery-resize/raw/master/jquery.ba-resize.js
// (Minified)   - http://github.com/cowboy/jquery-resize/raw/master/jquery.ba-resize.min.js (1.0kb)
// 
// About: License
// 
// Copyright (c) 2010 "Cowboy" Ben Alman,
// Dual licensed under the MIT and GPL licenses.
// http://benalman.com/about/license/
// 
// About: Examples
// 
// This working example, complete with fully commented code, illustrates a few
// ways in which this plugin can be used.
// 
// resize event - http://benalman.com/code/projects/jquery-resize/examples/resize/
// 
// About: Support and Testing
// 
// Information about what version or versions of jQuery this plugin has been
// tested with, what browsers it has been tested in, and where the unit tests
// reside (so you can test it yourself).
// 
// jQuery Versions - 1.3.2, 1.4.1, 1.4.2
// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1.
// Unit Tests      - http://benalman.com/code/projects/jquery-resize/unit/
// 
// About: Release History
// 
// 1.1 - (3/14/2010) Fixed a minor bug that was causing the event to trigger
//       immediately after bind in some circumstances. Also changed $.fn.data
//       to $.data to improve performance.
// 1.0 - (2/10/2010) Initial release
C
Catouse 已提交
646

C
Catouse 已提交
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
+function($,window,undefined){
  '$:nomunge'; // Used by YUI compressor.
  
  // A jQuery object containing all non-window elements to which the resize
  // event is bound.
  var elems = $([]),
    
    // Extend $.resize if it already exists, otherwise create it.
    jq_resize = $.resize = $.extend( $.resize, {} ),
    
    timeout_id,
    
    // Reused strings.
    str_setTimeout = 'setTimeout',
    str_resize = 'resize',
    str_data = str_resize + '-special-event',
    str_delay = 'delay',
    str_throttle = 'throttleWindow';
  
  // Property: jQuery.resize.delay
  // 
  // The numeric interval (in milliseconds) at which the resize event polling
  // loop executes. Defaults to 250.
  
  jq_resize[ str_delay ] = 250;
  
  // Property: jQuery.resize.throttleWindow
  // 
  // Throttle the native window object resize event to fire no more than once
  // every <jQuery.resize.delay> milliseconds. Defaults to true.
  // 
  // Because the window object has its own resize event, it doesn't need to be
  // provided by this plugin, and its execution can be left entirely up to the
  // browser. However, since certain browsers fire the resize event continuously
  // while others do not, enabling this will throttle the window resize event,
  // making event behavior consistent across all elements in all browsers.
  // 
  // While setting this property to false will disable window object resize
  // event throttling, please note that this property must be changed before any
  // window object resize event callbacks are bound.
  
  jq_resize[ str_throttle ] = true;
  
  // Event: resize event
  // 
  // Fired when an element's width or height changes. Because browsers only
  // provide this event for the window element, for other elements a polling
  // loop is initialized, running every <jQuery.resize.delay> milliseconds
  // to see if elements' dimensions have changed. You may bind with either
  // .resize( fn ) or .bind( "resize", fn ), and unbind with .unbind( "resize" ).
  // 
  // Usage:
  // 
  // > jQuery('selector').bind( 'resize', function(e) {
  // >   // element's width or height has changed!
  // >   ...
  // > });
  // 
  // Additional Notes:
  // 
  // * The polling loop is not created until at least one callback is actually
  //   bound to the 'resize' event, and this single polling loop is shared
  //   across all elements.
  // 
  // Double firing issue in jQuery 1.3.2:
  // 
  // While this plugin works in jQuery 1.3.2, if an element's event callbacks
  // are manually triggered via .trigger( 'resize' ) or .resize() those
  // callbacks may double-fire, due to limitations in the jQuery 1.3.2 special
  // events system. This is not an issue when using jQuery 1.4+.
  // 
  // > // While this works in jQuery 1.4+
  // > $(elem).css({ width: new_w, height: new_h }).resize();
  // > 
  // > // In jQuery 1.3.2, you need to do this:
  // > var elem = $(elem);
  // > elem.css({ width: new_w, height: new_h });
  // > elem.data( 'resize-special-event', { width: elem.width(), height: elem.height() } );
  // > elem.resize();
      
  $.event.special[ str_resize ] = {
    
    // Called only when the first 'resize' event callback is bound per element.
    setup: function() {
      // Since window has its own native 'resize' event, return false so that
      // jQuery will bind the event using DOM methods. Since only 'window'
      // objects have a .setTimeout method, this should be a sufficient test.
      // Unless, of course, we're throttling the 'resize' event for window.
      if ( !jq_resize[ str_throttle ] && this[ str_setTimeout ] ) { return false; }
      
      var elem = $(this);
      
      // Add this element to the list of internal elements to monitor.
      elems = elems.add( elem );
      
      // Initialize data store on the element.
      $.data( this, str_data, { w: elem.width(), h: elem.height() } );
      
      // If this is the first element added, start the polling loop.
      if ( elems.length === 1 ) {
        loopy();
C
Catouse 已提交
748
      }
C
Catouse 已提交
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
    },
    
    // Called only when the last 'resize' event callback is unbound per element.
    teardown: function() {
      // Since window has its own native 'resize' event, return false so that
      // jQuery will unbind the event using DOM methods. Since only 'window'
      // objects have a .setTimeout method, this should be a sufficient test.
      // Unless, of course, we're throttling the 'resize' event for window.
      if ( !jq_resize[ str_throttle ] && this[ str_setTimeout ] ) { return false; }
      
      var elem = $(this);
      
      // Remove this element from the list of internal elements to monitor.
      elems = elems.not( elem );
      
      // Remove any data stored on the element.
      elem.removeData( str_data );
      
      // If this is the last element removed, stop the polling loop.
      if ( !elems.length ) {
        clearTimeout( timeout_id );
      }
    },
    
    // Called every time a 'resize' event callback is bound per element (new in
    // jQuery 1.4).
    add: function( handleObj ) {
      // Since window has its own native 'resize' event, return false so that
      // jQuery doesn't modify the event object. Unless, of course, we're
      // throttling the 'resize' event for window.
      if ( !jq_resize[ str_throttle ] && this[ str_setTimeout ] ) { return false; }
      
      var old_handler;
      
      // The new_handler function is executed every time the event is triggered.
      // This is used to update the internal element data store with the width
      // and height when the event is triggered manually, to avoid double-firing
      // of the event callback. See the "Double firing issue in jQuery 1.3.2"
      // comments above for more information.
      
      function new_handler( e, w, h ) {
        var elem = $(this),
          data = $.data( this, str_data );
        
        // If called from the polling loop, w and h will be passed in as
        // arguments. If called manually, via .trigger( 'resize' ) or .resize(),
        // those values will need to be computed.
        data.w = w !== undefined ? w : elem.width();
        data.h = h !== undefined ? h : elem.height();
        
        old_handler.apply( this, arguments );
      };
      
      // This may seem a little complicated, but it normalizes the special event
      // .add method between jQuery 1.4/1.4.1 and 1.4.2+
      if ( $.isFunction( handleObj ) ) {
        // 1.4, 1.4.1
        old_handler = handleObj;
        return new_handler;
      } else {
        // 1.4.2+
        old_handler = handleObj.handler;
        handleObj.handler = new_handler;
C
Catouse 已提交
812 813
      }
    }
C
Catouse 已提交
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
    
  };
  
  function loopy() {
    
    // Start the polling loop, asynchronously.
    timeout_id = window[ str_setTimeout ](function(){
      
      // Iterate over all elements to which the 'resize' event is bound.
      elems.each(function(){
        var elem = $(this),
          width = elem.width(),
          height = elem.height(),
          data = $.data( this, str_data );
        
        // If element size has changed since the last time, update the element
        // data store and trigger the 'resize' event.
        if ( width !== data.w || height !== data.h ) {
          elem.trigger( str_resize, [ data.w = width, data.h = height ] );
        }
        
      });
      
      // Loop.
      loopy();
      
    }, jq_resize[ str_delay ] );
    
  };
  
}(jQuery,this);
C
Catouse 已提交
845

C
Catouse 已提交
846 847 848 849
/* Store */
+function(window, $)
{
    "use strict";
C
Catouse 已提交
850

C
Catouse 已提交
851 852 853 854
    var lsName = 'localStorage';
    var storage = window[lsName],
        old = window.store,
        pageName = 'page_' + window.location.pathname;
C
Catouse 已提交
855

C
Catouse 已提交
856 857 858 859 860 861
    /* The Store object */
    var Store = function()
    {
        this.slience = true;
        this.enable = (lsName in window) && window[lsName] && window[lsName].setItem;
        this.storage = storage;
C
Catouse 已提交
862

C
Catouse 已提交
863 864
        this.page = this.get(pageName, {});
    };
C
Catouse 已提交
865

C
Catouse 已提交
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
    /* Save page data */
    Store.prototype.pageSave = function()
    {
        if($.isEmptyObject(this.page))
        {
            this.remove(pageName);
        }
        else
        {
            var forDeletes = [];
            for(var i in this.page)
            {
                var val = this.page[i];
                if(val === null)
                    forDeletes.push(i);
            }
            for (var i = forDeletes.length - 1; i >= 0; i--)
            {
                delete this.page[forDeletes[i]];
            }
            this.set(pageName, this.page);
        }
    };
C
Catouse 已提交
889

C
Catouse 已提交
890 891 892 893 894 895 896 897 898
    /* Remove page data item */
    Store.prototype.pageRemove = function(key)
    {
        if(typeof this.page[key] != 'undefined')
        {
            this.page[key] = null;
            this.pageSave();
        }
    };
C
Catouse 已提交
899

C
Catouse 已提交
900 901 902 903 904 905
    /* Clear page data */
    Store.prototype.pageClear = function()
    {
        this.page = {};
        this.pageSave();
    };
C
Catouse 已提交
906

C
Catouse 已提交
907 908 909 910 911 912
    /* Get page data */
    Store.prototype.pageGet = function(key, defaultValue)
    {
        var val = this.page[key];
        return (defaultValue !== undefined && (val === null || val === undefined)) ? defaultValue : val;
    };
C
Catouse 已提交
913

C
Catouse 已提交
914 915 916 917 918 919 920 921 922 923 924 925 926
    /* Set page data */
    Store.prototype.pageSet = function(objOrKey, val)
    {
        if($.isPlainObject(objOrKey))
        {
            $.extend(true, this.page, objOrKey);
        }
        else
        {
            this.page[this.serialize(objOrKey)] = val;
        }
        this.pageSave();
    };
C
Catouse 已提交
927

C
Catouse 已提交
928 929 930 931 932 933 934 935 936
    /* Check enable status */
    Store.prototype.check = function()
    {
        if(!this.enable)
        {
            if(!this.slience) throw new Error('Browser not support localStorage or enable status been set true.');
        }
        return this.enable;
    };
C
Catouse 已提交
937

C
Catouse 已提交
938 939 940 941 942 943 944 945 946
    /* Get length */
    Store.prototype.length = function()
    {
        if(this.check())
        {
            return storage.length;
        }
        return 0;
    };
C
Catouse 已提交
947

C
Catouse 已提交
948 949 950 951 952
    /* Remove item with browser localstorage native method */
    Store.prototype.removeItem = function(key)
    {
        storage.removeItem(key);
    };
C
Catouse 已提交
953

C
Catouse 已提交
954 955 956 957 958
    /* Remove item with browser localstorage native method, same as removeItem */
    Store.prototype.remove = function(key)
    {
        this.removeItem(key);
    };
C
Catouse 已提交
959

C
Catouse 已提交
960 961 962 963 964
    /* Get item value with browser localstorage native method, and without deserialize */
    Store.prototype.getItem = function(key)
    {
        return storage.getItem(key);
    };
C
Catouse 已提交
965

C
Catouse 已提交
966 967 968 969 970 971
    /* Get item value and deserialize it, if value is null and defaultValue been given then return defaultValue */
    Store.prototype.get = function(key, defaultValue)
    {
        var val = this.deserialize(this.getItem(key));
        return (defaultValue !== undefined && (val === null || val === undefined)) ? defaultValue : val;
    };
C
Catouse 已提交
972

C
Catouse 已提交
973 974 975 976 977
    /* Get item key by index and deserialize it */
    Store.prototype.key = function(index)
    {
        return storage.key(index);
    };
C
Catouse 已提交
978

C
Catouse 已提交
979 980 981 982 983
    /* Set item value with browser localstorage native method, and without serialize filter */
    Store.prototype.setItem = function(key, val)
    {
        storage.setItem(key, val);
    };
C
Catouse 已提交
984

C
Catouse 已提交
985 986 987 988 989 990
    /* Set item value, serialize it if the given value is not an string */
    Store.prototype.set = function(key, val)
    {
        if(val === undefined) return this.remove(key);
        this.setItem(key, this.serialize(val));
    };
C
Catouse 已提交
991

C
Catouse 已提交
992 993 994 995 996
    /* Clear all items with browser localstorage native method */
    Store.prototype.clear = function()
    {
        storage.clear();
    };
C
Catouse 已提交
997

C
Catouse 已提交
998 999 1000 1001 1002 1003 1004 1005 1006
    /* Iterate all items with callback */
    Store.prototype.forEach = function(callback)
    {
        for(var i = 0; i < storage.length; i++)
        {
            var key = storage.key(i);
            callback(key, this.get(key));
        }
    };
C
Catouse 已提交
1007

C
Catouse 已提交
1008 1009 1010 1011 1012 1013 1014 1015
    /* Get all items and set value in an object. */
    Store.prototype.getAll = function()
    {
        var all = {};
        this.forEach(function(key, val)
        {
            all[key] = val;
        });
C
Catouse 已提交
1016

C
Catouse 已提交
1017 1018
        return all;
    };
C
Catouse 已提交
1019

C
Catouse 已提交
1020 1021 1022 1023 1024 1025
    /* Serialize value with JSON.stringify */
    Store.prototype.serialize = function(value)
    {
        if(typeof value === 'string') return value;
        return JSON.stringify(value);
    };
C
Catouse 已提交
1026

C
Catouse 已提交
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
    /* Deserialize value, with JSON.parse if the given value is not a string */
    Store.prototype.deserialize = function(value)
    {
        if(typeof value !== 'string') return undefined;
        try
        {
            return JSON.parse(value);
        }
        catch(e)
        {
            return value || undefined;
        }
    };
C
Catouse 已提交
1040

C
Catouse 已提交
1041
    var store = new Store();
C
Catouse 已提交
1042

C
Catouse 已提交
1043
    window.store = store;
C
Catouse 已提交
1044

C
Catouse 已提交
1045 1046 1047 1048 1049 1050
    window.store.noConflict = function()
    {
        window.store = old;
        return store;
    };
}(window, jQuery);
C
Catouse 已提交
1051 1052

/* ========================================================================
C
Catouse 已提交
1053 1054
 * Bootstrap: tab.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#tabs
C
Catouse 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */


+function ($) { "use strict";

C
Catouse 已提交
1074 1075
  // TAB CLASS DEFINITION
  // ====================
C
Catouse 已提交
1076

C
Catouse 已提交
1077 1078
  var Tab = function (element) {
    this.element = $(element)
C
Catouse 已提交
1079 1080
  }

C
Catouse 已提交
1081 1082 1083 1084
  Tab.prototype.show = function () {
    var $this    = this.element
    var $ul      = $this.closest('ul:not(.dropdown-menu)')
    var selector = $this.attr('data-target')
C
Catouse 已提交
1085

C
Catouse 已提交
1086 1087 1088
    if (!selector) {
      selector = $this.attr('href')
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
C
Catouse 已提交
1089 1090
    }

C
Catouse 已提交
1091
    if ($this.parent('li').hasClass('active')) return
C
Catouse 已提交
1092

C
Catouse 已提交
1093 1094 1095 1096
    var previous = $ul.find('.active:last a')[0]
    var e        = $.Event('show.bs.tab', {
      relatedTarget: previous
    })
C
Catouse 已提交
1097

C
Catouse 已提交
1098
    $this.trigger(e)
C
Catouse 已提交
1099

C
Catouse 已提交
1100
    if (e.isDefaultPrevented()) return
C
Catouse 已提交
1101

C
Catouse 已提交
1102
    var $target = $(selector)
C
Catouse 已提交
1103

C
Catouse 已提交
1104 1105 1106 1107 1108 1109
    this.activate($this.parent('li'), $ul)
    this.activate($target, $target.parent(), function () {
      $this.trigger({
        type: 'shown.bs.tab'
      , relatedTarget: previous
      })
C
Catouse 已提交
1110 1111 1112
    })
  }

C
Catouse 已提交
1113 1114 1115 1116 1117
  Tab.prototype.activate = function (element, container, callback) {
    var $active    = container.find('> .active')
    var transition = callback
      && $.support.transition
      && $active.hasClass('fade')
C
Catouse 已提交
1118

C
Catouse 已提交
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
    function next() {
      $active
        .removeClass('active')
        .find('> .dropdown-menu > .active')
        .removeClass('active')

      element.addClass('active')

      if (transition) {
        element[0].offsetWidth // reflow for transition
        element.addClass('in')
      } else {
        element.removeClass('fade')
      }

      if (element.parent('.dropdown-menu')) {
        element.closest('li.dropdown').addClass('active')
      }

      callback && callback()
C
Catouse 已提交
1139 1140
    }

C
Catouse 已提交
1141 1142 1143 1144 1145
    transition ?
      $active
        .one($.support.transition.end, next)
        .emulateTransitionEnd(150) :
      next()
C
Catouse 已提交
1146

C
Catouse 已提交
1147
    $active.removeClass('in')
C
Catouse 已提交
1148 1149 1150
  }


C
Catouse 已提交
1151 1152
  // TAB PLUGIN DEFINITION
  // =====================
C
Catouse 已提交
1153

C
Catouse 已提交
1154
  var old = $.fn.tab
C
Catouse 已提交
1155

C
Catouse 已提交
1156
  $.fn.tab = function ( option ) {
C
Catouse 已提交
1157 1158
    return this.each(function () {
      var $this = $(this)
C
Catouse 已提交
1159
      var data  = $this.data('bs.tab')
C
Catouse 已提交
1160

C
Catouse 已提交
1161 1162
      if (!data) $this.data('bs.tab', (data = new Tab(this)))
      if (typeof option == 'string') data[option]()
C
Catouse 已提交
1163 1164 1165
    })
  }

C
Catouse 已提交
1166
  $.fn.tab.Constructor = Tab
C
Catouse 已提交
1167 1168


C
Catouse 已提交
1169 1170
  // TAB NO CONFLICT
  // ===============
C
Catouse 已提交
1171

C
Catouse 已提交
1172 1173
  $.fn.tab.noConflict = function () {
    $.fn.tab = old
C
Catouse 已提交
1174 1175 1176 1177
    return this
  }


C
Catouse 已提交
1178 1179
  // TAB DATA-API
  // ============
C
Catouse 已提交
1180

C
Catouse 已提交
1181 1182 1183 1184
  $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
    e.preventDefault()
    $(this).tab('show')
  })
C
Catouse 已提交
1185 1186 1187 1188

}(window.jQuery);

/* ========================================================================
C
Catouse 已提交
1189 1190
 * Bootstrap: modal.js v3.2.0
 * http://getbootstrap.com/javascript/#modals
C
Catouse 已提交
1191
 * ========================================================================
C
Catouse 已提交
1192 1193 1194 1195 1196 1197 1198
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ========================================================================
 * Updates in ZUI:
 * 1. changed event namespace to *.zui.modal
 * 2. added position option to ajust poisition of modal
 * 3. added event 'escaping.bs.modal' with an param 'esc' to judge the esc key down
C
Catouse 已提交
1199 1200
 * ======================================================================== */

C
Catouse 已提交
1201 1202
+function ($) {
  'use strict';
C
Catouse 已提交
1203 1204 1205 1206 1207

  // MODAL CLASS DEFINITION
  // ======================

  var Modal = function (element, options) {
C
Catouse 已提交
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
    this.options        = options
    this.$body          = $(document.body)
    this.$element       = $(element)
    this.$backdrop      =
    this.isShown        = null
    this.scrollbarWidth = 0

    if (this.options.remote) {
      this.$element
        .find('.modal-content')
        .load(this.options.remote, $.proxy(function () {
          this.$element.trigger('loaded.zui.modal')
        }, this))
    }
C
Catouse 已提交
1222 1223
  }

C
Catouse 已提交
1224 1225 1226 1227 1228
  Modal.VERSION  = '3.2.0'

  Modal.TRANSITION_DURATION = 300
  Modal.BACKDROP_TRANSITION_DURATION = 150

C
Catouse 已提交
1229
  Modal.DEFAULTS = {
C
Catouse 已提交
1230 1231 1232 1233
    backdrop: true,
    keyboard: true,
    show: true,
    position: 'fit' // 'center' or '40px' or '10%'
C
Catouse 已提交
1234 1235
  }

C
Catouse 已提交
1236 1237
  Modal.prototype.toggle = function (_relatedTarget, position) {
    return this.isShown ? this.hide() : this.show(_relatedTarget, position)
C
Catouse 已提交
1238 1239
  }

C
Catouse 已提交
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
  Modal.prototype.ajustPosition = function(position)
  {
      if(typeof position === 'undefined') position = this.options.position;
      if(typeof position === 'undefined') return;
      var $dialog = this.$element.find('.modal-dialog');
      var half = Math.max(0, ($(window).height() - $dialog.outerHeight())/2);
      var pos = position == 'fit' ? (half*2/3) : (position == 'center' ? half : position);
      $dialog.css('margin-top', pos);
  }

  Modal.prototype.show = function (_relatedTarget, position) {
C
Catouse 已提交
1251
    var that = this
C
Catouse 已提交
1252
    var e    = $.Event('show.zui.modal', { relatedTarget: _relatedTarget })
C
Catouse 已提交
1253 1254 1255 1256 1257 1258 1259

    this.$element.trigger(e)

    if (this.isShown || e.isDefaultPrevented()) return

    this.isShown = true

C
Catouse 已提交
1260 1261 1262 1263
    this.checkScrollbar()
    this.$body.addClass('modal-open')

    this.setScrollbar()
C
Catouse 已提交
1264 1265
    this.escape()

C
Catouse 已提交
1266
    this.$element.on('click.dismiss.zui.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
C
Catouse 已提交
1267 1268 1269 1270 1271

    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')

      if (!that.$element.parent().length) {
C
Catouse 已提交
1272
        that.$element.appendTo(that.$body) // don't move modals dom position
C
Catouse 已提交
1273 1274
      }

C
Catouse 已提交
1275 1276 1277
      that.$element
        .show()
        .scrollTop(0)
C
Catouse 已提交
1278 1279 1280 1281 1282 1283 1284 1285 1286

      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }

      that.$element
        .addClass('in')
        .attr('aria-hidden', false)

C
Catouse 已提交
1287
      that.ajustPosition(position);
C
Catouse 已提交
1288 1289 1290

      that.enforceFocus()

C
Catouse 已提交
1291
      var e = $.Event('shown.zui.modal', { relatedTarget: _relatedTarget })
C
Catouse 已提交
1292 1293 1294

      transition ?
        that.$element.find('.modal-dialog') // wait for modal to slide in
C
Catouse 已提交
1295 1296
          .one('bsTransitionEnd', function () {
            that.$element.trigger('focus').trigger(e)
C
Catouse 已提交
1297
          })
C
Catouse 已提交
1298 1299
          .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
        that.$element.trigger('focus').trigger(e)
C
Catouse 已提交
1300 1301 1302 1303 1304 1305
    })
  }

  Modal.prototype.hide = function (e) {
    if (e) e.preventDefault()

C
Catouse 已提交
1306
    e = $.Event('hide.zui.modal')
C
Catouse 已提交
1307 1308 1309 1310 1311 1312 1313

    this.$element.trigger(e)

    if (!this.isShown || e.isDefaultPrevented()) return

    this.isShown = false

C
Catouse 已提交
1314 1315 1316
    this.$body.removeClass('modal-open')

    this.resetScrollbar()
C
Catouse 已提交
1317 1318
    this.escape()

C
Catouse 已提交
1319
    $(document).off('focusin.zui.modal')
C
Catouse 已提交
1320 1321 1322 1323

    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
C
Catouse 已提交
1324
      .off('click.dismiss.zui.modal')
C
Catouse 已提交
1325 1326 1327

    $.support.transition && this.$element.hasClass('fade') ?
      this.$element
C
Catouse 已提交
1328 1329
        .one('bsTransitionEnd', $.proxy(this.hideModal, this))
        .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
C
Catouse 已提交
1330 1331 1332 1333 1334
      this.hideModal()
  }

  Modal.prototype.enforceFocus = function () {
    $(document)
C
Catouse 已提交
1335 1336
      .off('focusin.zui.modal') // guard against infinite focus loop
      .on('focusin.zui.modal', $.proxy(function (e) {
C
Catouse 已提交
1337
        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
C
Catouse 已提交
1338
          this.$element.trigger('focus')
C
Catouse 已提交
1339 1340 1341 1342 1343 1344
        }
      }, this))
  }

  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
C
Catouse 已提交
1345 1346
      $(document).on('keydown.dismiss.zui.modal', $.proxy(function (e)
      {
C
Catouse 已提交
1347 1348 1349 1350 1351 1352 1353 1354 1355
        if(e.which == 27)
        {
            var et = $.Event('escaping.bs.modal')
            var result = this.$element.triggerHandler(et, 'esc')
            if(result != undefined && (!result)) return
            this.hide()
        }
      }, this))
    } else if (!this.isShown) {
C
Catouse 已提交
1356
      $(document).off('keydown.dismiss.zui.modal')
C
Catouse 已提交
1357 1358 1359 1360 1361 1362 1363
    }
  }

  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
C
Catouse 已提交
1364
      that.$element.trigger('hidden.zui.modal')
C
Catouse 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373
    })
  }

  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }

  Modal.prototype.backdrop = function (callback) {
C
Catouse 已提交
1374
    var that = this
C
Catouse 已提交
1375 1376 1377 1378 1379 1380
    var animate = this.$element.hasClass('fade') ? 'fade' : ''

    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate

      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
C
Catouse 已提交
1381
        .appendTo(this.$body)
C
Catouse 已提交
1382

C
Catouse 已提交
1383
      this.$element.on('mousedown.dismiss.zui.modal', $.proxy(function (e) {
C
Catouse 已提交
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
      }, this))

      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow

      this.$backdrop.addClass('in')

      if (!callback) return

      doAnimate ?
        this.$backdrop
C
Catouse 已提交
1398 1399
          .one('bsTransitionEnd', callback)
          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
C
Catouse 已提交
1400 1401 1402 1403 1404
        callback()

    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')

C
Catouse 已提交
1405 1406 1407 1408 1409
      var callbackRemove = function () {
        that.removeBackdrop()
        callback && callback()
      }
      $.support.transition && this.$element.hasClass('fade') ?
C
Catouse 已提交
1410
        this.$backdrop
C
Catouse 已提交
1411 1412 1413
          .one('bsTransitionEnd', callbackRemove)
          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
        callbackRemove()
C
Catouse 已提交
1414 1415 1416 1417 1418 1419

    } else if (callback) {
      callback()
    }
  }

C
Catouse 已提交
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442
  Modal.prototype.checkScrollbar = function () {
    if (document.body.clientWidth >= window.innerWidth) return
    this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
  }

  Modal.prototype.setScrollbar = function () {
    var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
    if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
  }

  Modal.prototype.resetScrollbar = function () {
    this.$body.css('padding-right', '')
  }

  Modal.prototype.measureScrollbar = function () { // thx walsh
    var scrollDiv = document.createElement('div')
    scrollDiv.className = 'modal-scrollbar-measure'
    this.$body.append(scrollDiv)
    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
    this.$body[0].removeChild(scrollDiv)
    return scrollbarWidth
  }

C
Catouse 已提交
1443 1444 1445 1446

  // MODAL PLUGIN DEFINITION
  // =======================

C
Catouse 已提交
1447
  function Plugin(option, _relatedTarget, position) {
C
Catouse 已提交
1448 1449
    return this.each(function () {
      var $this   = $(this)
C
Catouse 已提交
1450
      var data    = $this.data('zui.modal')
C
Catouse 已提交
1451 1452
      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)

C
Catouse 已提交
1453 1454 1455
      if (!data) $this.data('zui.modal', (data = new Modal(this, options)))
      if (typeof option == 'string') data[option](_relatedTarget, position)
      else if (options.show) data.show(_relatedTarget, position)
C
Catouse 已提交
1456 1457 1458
    })
  }

C
Catouse 已提交
1459 1460 1461
  var old = $.fn.modal

  $.fn.modal             = Plugin
C
Catouse 已提交
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476
  $.fn.modal.Constructor = Modal


  // MODAL NO CONFLICT
  // =================

  $.fn.modal.noConflict = function () {
    $.fn.modal = old
    return this
  }


  // MODAL DATA-API
  // ==============

C
Catouse 已提交
1477
  $(document).on('click.zui.modal.data-api', '[data-toggle="modal"]', function (e) {
C
Catouse 已提交
1478 1479
    var $this   = $(this)
    var href    = $this.attr('href')
C
Catouse 已提交
1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
    var $target = null
    try
    {
        // strip for ie7
        $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
    } catch(ex){return}
    if(!$target.length) return;
    var option  = $target.data('zui.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())

    if ($this.is('a')) e.preventDefault()

    $target.one('show.zui.modal', function (showEvent) {
      // only register focus restorer if modal will actually get shown
      if (showEvent.isDefaultPrevented()) return
      $target.one('hidden.zui.modal', function () {
        $this.is(':visible') && $this.trigger('focus')
C
Catouse 已提交
1496
      })
C
Catouse 已提交
1497 1498
    })
    Plugin.call($target, option, this, $this.data('position'))
C
Catouse 已提交
1499 1500
  })

C
Catouse 已提交
1501
}(jQuery);
C
Catouse 已提交
1502

C
Catouse 已提交
1503 1504 1505 1506 1507 1508
/* ========================================================================
 * ZUI: modal.trigger.js v1.2.0
 * http://zui.sexy/docs/javascript.html#modals
 * Licensed under MIT
 * ======================================================================== */
+function($)
C
Catouse 已提交
1509 1510 1511
{
    "use strict";

C
Catouse 已提交
1512
    if(!$.fn.modal) throw new Error('Modal trigger requires modal.js')
C
Catouse 已提交
1513

C
Catouse 已提交
1514 1515 1516
    // ONCE MODAL CLASS DEFINITION
    // ======================
    var ModalTrigger = function(options)
C
Catouse 已提交
1517
    {
C
Catouse 已提交
1518 1519
        options      = $.extend({}, ModalTrigger.DEFAULTS, $.ModalTriggerDefaults, options);
        this.$modal;
C
Catouse 已提交
1520 1521 1522
        this.isShown = false;
        this.options = options;
        this.id      = $.uuid();
C
Catouse 已提交
1523

C
Catouse 已提交
1524
        // todo: handle when: options.show = true
C
Catouse 已提交
1525 1526 1527 1528
    };

    ModalTrigger.DEFAULTS =
    {
C
Catouse 已提交
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
        type       : 'custom',
        width      : null, // number, css definition
        size       : null, // 'md', 'sm', 'lg', 'fullscreen'
        height     : 'auto',
        icon       : null,
        name       : 'triggerModal',
        fade       : true,
        position   : 'fit',
        showHeader : true,
        delay      : 0,
        backdrop   : true,
        keyboard   : true
C
Catouse 已提交
1541 1542
    };

C
Catouse 已提交
1543
    ModalTrigger.prototype.init = function(options)
C
Catouse 已提交
1544
    {
C
Catouse 已提交
1545 1546
        var that = this;
        if(options.url)
C
Catouse 已提交
1547
        {
C
Catouse 已提交
1548 1549 1550 1551
            if(!options.type || (options.type != 'ajax' && options.type != 'iframe'))
            {
                options.type = 'ajax';
            }
C
Catouse 已提交
1552
        }
C
Catouse 已提交
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569
        if(options.remote)
        {
            options.type = 'ajax';
            if(typeof options.remote === 'string') options.url = options.remote;
        }
        else if(options.iframe)
        {
            options.type = 'iframe';
            if(typeof options.iframe === 'string') options.url = options.iframe;
        }
        else if(options.custom)
        {
            options.type = 'custom';
            if(typeof options.custom === 'string')
            {
                var $doms;
                try {$doms = $(options.custom);} catch(e){}
C
Catouse 已提交
1570

C
Catouse 已提交
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580
                if($doms && $doms.length)
                {
                    options.custom = $doms;
                }
                else if($.isFunction(window[options.custom]))
                {
                    options.custom = window[options.custom];
                }
            }
        }
C
Catouse 已提交
1581

C
Catouse 已提交
1582
        var $modal = $('#' + options.name);
C
Catouse 已提交
1583 1584 1585 1586 1587 1588 1589 1590
        if($modal.length)
        {
            if(!this.isShown) $modal.off('.zui.modal');
            $modal.remove();
        }
        $modal = $('<div id="' + options.name + '" class="modal modal-trigger"><div class="icon-spinner icon-spin loader"></div><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button class="close" data-dismiss="modal">×</button><h4 class="modal-title"><i class="modal-icon"></i> <span class="modal-title-name"></span></h4></div><div class="modal-body"></div></div></div></div>').appendTo('body');

        var bindEvent = function(optonName, eventName)
C
Catouse 已提交
1591
        {
C
Catouse 已提交
1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606
            var handleFunc = options[optonName];
            if($.isFunction(handleFunc)) $modal.on(eventName + '.zui.modal', handleFunc);
        };
        bindEvent('onShow', 'show');
        bindEvent('shown', 'shown');
        bindEvent('onHide', 'hide');
        bindEvent('hidden', 'hidden');
        bindEvent('loaded', 'loaded');

        $modal.on('shown.zui.modal', function() {that.isShown = true;})
        $modal.on('hidden.zui.modal', function() {that.isShown = false;})

        this.$modal = $modal;
        this.$dialog = $modal.find('.modal-dialog');
    }
C
Catouse 已提交
1607

C
Catouse 已提交
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
    ModalTrigger.prototype.show = function(option)
    {
        var options = $.extend({}, this.options, option);
        this.init(options);
        var that    = this,
            $modal  = this.$modal,
            $dialog = this.$dialog,
            custom  = options.custom;
        var $body   = $dialog.find('.modal-body').css('padding', ''),
            $header = $dialog.find('.modal-header'),
            $content= $dialog.find('.modal-content');

        $modal.toggleClass('fade', options.fade)
              .addClass(options.cssClass)
              .toggleClass('modal-md', options.size === 'md')
              .toggleClass('modal-sm', options.size === 'sm')
              .toggleClass('modal-lg', options.size === 'lg')
              .toggleClass('modal-fullscreen', options.size === 'fullscreen')
              .toggleClass('modal-loading', !this.isShown);
        $header.toggle(options.showHeader);
        $header.find('.modal-icon').attr('class', 'modal-icon icon-' + options.icon);
        $header.find('.modal-title-name').html(options.title || '');
        if(options.size && options.size === 'fullscreen')
        {
            options.width  = '';
            options.height = '';
        }
C
Catouse 已提交
1635

C
Catouse 已提交
1636 1637 1638 1639 1640
        var readyToShow = function(delay)
        {
            if(typeof delay === 'undefined') delay = 300;
            // $modal.removeClass('fade');
            setTimeout(function()
C
Catouse 已提交
1641
            {
C
Catouse 已提交
1642 1643 1644 1645 1646 1647 1648 1649 1650
                $dialog = $modal.find('.modal-dialog');
                if(options.width && options.width != 'auto')
                {
                    $dialog.css('width', options.width);
                }
                if(options.height && options.height != 'auto') $dialog.css('height', options.height);
                that.ajustPosition(options.position);
                // if(options.fade) $modal.addClass('fade');
                $modal.removeClass('modal-loading');
C
Catouse 已提交
1651

C
Catouse 已提交
1652 1653 1654 1655 1656 1657
                if(options.type != 'iframe')
                {
                    $dialog.off('resize.zui.modaltrigger').on('resize.zui.modaltrigger', function(){that.ajustPosition();});
                }
            }, delay);
        };
C
Catouse 已提交
1658

C
Catouse 已提交
1659 1660 1661
        if(options.type === 'custom' && custom)
        {
            if($.isFunction(custom))
C
Catouse 已提交
1662
            {
C
Catouse 已提交
1663 1664
                var customContent = custom({modal: $modal, options: options, modalTrigger: that, ready: readyToShow});
                if(typeof customContent === 'string')
C
Catouse 已提交
1665
                {
C
Catouse 已提交
1666 1667 1668
                    $body.html(customContent);
                    readyToShow();
                }
C
Catouse 已提交
1669
            }
C
Catouse 已提交
1670
            else if(custom instanceof $)
C
Catouse 已提交
1671
            {
C
Catouse 已提交
1672 1673
                $body.html($('<div>').append(custom.clone()).html());
                readyToShow();
C
Catouse 已提交
1674 1675 1676
            }
            else
            {
C
Catouse 已提交
1677 1678 1679 1680 1681 1682
                $body.html(custom);
                readyToShow();
            }
        }
        else if(options.url)
        {
C
Catouse 已提交
1683
            $modal.attr('ref', options.url);
C
Catouse 已提交
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695
            if(options.type === 'iframe')
            {
                $modal.addClass('modal-iframe');
                this.firstLoad = true;
                var iframeName = 'iframe-' + options.name;
                $header.detach();
                $body.detach();
                $content.empty().append($header).append($body);
                $body.css('padding', 0)
                     .html('<iframe id="' + iframeName + '" name="' + iframeName + '" src="' + options.url + '" frameborder="no" allowtransparency="true" scrolling="auto" style="width: 100%; height: 100%; left: 0px;"></iframe>');

                if(options.waittime > 0)
C
Catouse 已提交
1696
                {
C
Catouse 已提交
1697
                    that.waitTimeout = setTimeout(readyToShow, options.waittime);
C
Catouse 已提交
1698 1699
                }

C
Catouse 已提交
1700
                var frame = document.getElementById(iframeName);
C
Catouse 已提交
1701 1702
                frame.onload = frame.onreadystatechange = function()
                {
C
Catouse 已提交
1703
                    $modal.attr('ref', frame.contentWindow.location.href);
C
Catouse 已提交
1704 1705 1706
                    if(that.firstLoad) $modal.addClass('modal-loading');
                    if(this.readyState && this.readyState != 'complete') return;
                    that.firstLoad = false;
C
Catouse 已提交
1707

C
Catouse 已提交
1708
                    if(options.waittime > 0)
C
Catouse 已提交
1709
                    {
C
Catouse 已提交
1710 1711
                        clearTimeout(that.waitTimeout);
                    }
C
Catouse 已提交
1712

C
Catouse 已提交
1713 1714 1715 1716
                    try
                    {
                        var frame$ = window.frames[iframeName].$;
                        if(frame$ && options.height === 'auto' && options.size != 'fullscreen')
C
Catouse 已提交
1717
                        {
C
Catouse 已提交
1718
                            // todo: update iframe url to ref attribute
C
Catouse 已提交
1719 1720
                            var $framebody = frame$('body').addClass('body-modal');
                            var ajustFrameSize = function()
C
Catouse 已提交
1721
                            {
C
Catouse 已提交
1722 1723 1724 1725 1726 1727
                                $modal.removeClass('fade');
                                var height = $framebody.outerHeight();
                                $body.css('height', height);
                                if(options.fade) $modal.addClass('fade');
                                readyToShow();
                            };
C
Catouse 已提交
1728

C
Catouse 已提交
1729
                            $modal.callEvent('loaded.zui.modal', {modalType: 'iframe'});
C
Catouse 已提交
1730

C
Catouse 已提交
1731 1732 1733
                            setTimeout(ajustFrameSize, 100);

                            $frameBody.off('resize.zui.modaltrigger').on('resize.zui.modaltrigger', ajustFrameSize);
C
Catouse 已提交
1734
                        }
C
Catouse 已提交
1735 1736

                        frame$.extend({closeModal: that.close});
C
Catouse 已提交
1737
                    }
C
Catouse 已提交
1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
                    catch(e)
                    {
                        readyToShow();
                    }
                };
            }
            else
            {
                $.get(options.url, function(data)
                {
                    var $data = $(data);
                    if($data.hasClass('modal-dialog'))
                    {
                        $dialog.replaceWith($data);
                    }
                    else if($data.hasClass('modal-content'))
                    {
                        $dialog.find('.modal-content').replaceWith($data);
                    }
                    else
                    {
                        $body.wrapInner($data);
                    }
                    $modal.callEvent('loaded.zui.modal', {modalType: 'ajax'});
                    readyToShow();
                });
C
Catouse 已提交
1764
            }
C
Catouse 已提交
1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
        }

        $modal.modal({show: 'show', backdrop: options.backdrop, keyboard: options.keyboard});
    };

    ModalTrigger.prototype.close = function(callback, redirect)
    {
        this.$modal.on('hidden.zui.modal', function()
        {
            if($.isFunction(callback)) callback();

            if(typeof redirect === 'string')
            {
                if(redirect === 'this') window.location.reload();
                else window.location = redirect;
            }
        }).modal('hide');
    };

    ModalTrigger.prototype.toggle = function(options)
    {
        if(this.isShown) this.close();
        else this.show(options);
    };
C
Catouse 已提交
1789

C
Catouse 已提交
1790 1791 1792 1793
    ModalTrigger.prototype.ajustPosition = function(position)
    {
        this.$modal.modal('ajustPosition', position || this.options.position);
    };
C
Catouse 已提交
1794

C
Catouse 已提交
1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
    window.ModalTrigger = ModalTrigger;
    window.modalTrigger = new ModalTrigger();

    $.fn.modalTrigger = function(option, settings)
    {
        return $(this).each(function()
        {
            var $this = $(this);
            var data    = $this.data('zui.modaltrigger'),
                options = $.extend(
                {
                    title: $this.attr('title') || $this.text(),
                    url  : $this.attr('href'),
                    type : $this.hasClass('iframe') ? 'iframe' : ''
                }, $this.data(), $.isPlainObject(option) && option);
            if(!data) $this.data('zui.modaltrigger', (data = new ModalTrigger(options)));
            if (typeof option == 'string') data[option](settings);
            else if(options.show) data.show(settings);

            $this.on((options.trigger || 'click') + '.toggle.zui.modaltrigger', function(e)
            {
                data.toggle(options);
                if($this.is('a')) e.preventDefault();
            });
        });
    };

    var old = $.fn.modal;
    $.fn.modal = function(option, settings)
    {
        return $(this).each(function()
        {
            var $this = $(this);
            if($this.hasClass('modal')) old.call($this, option, settings);
            else $this.modalTrigger(option, settings);
C
Catouse 已提交
1830 1831 1832
        });
    };

C
Catouse 已提交
1833
    function getModal(modal)
C
Catouse 已提交
1834
    {
C
Catouse 已提交
1835 1836
        var modalType = typeof(modal);
        if(modalType === 'undefined')
C
Catouse 已提交
1837
        {
C
Catouse 已提交
1838
            modal = $('.modal.modal-once');
C
Catouse 已提交
1839
        }
C
Catouse 已提交
1840
        else if(modalType === 'string')
C
Catouse 已提交
1841
        {
C
Catouse 已提交
1842
            modal = $('#' + modal).replace('##', '#');
C
Catouse 已提交
1843
        }
C
Catouse 已提交
1844 1845 1846
        if(modal && (modal instanceof $)) return modal;
        return null;
    }
C
Catouse 已提交
1847

C
Catouse 已提交
1848 1849 1850 1851
    window.closeModal = function(callback, redirect, modal)
    {
        modal = getModal(modal);
        if(modal && modal.length)
C
Catouse 已提交
1852
        {
C
Catouse 已提交
1853
            modal.each(function()
C
Catouse 已提交
1854
            {
C
Catouse 已提交
1855
                $(this).data('zui.modaltrigger').close(callback, redirect);
C
Catouse 已提交
1856
            });
C
Catouse 已提交
1857
        }
C
Catouse 已提交
1858 1859
    };

C
Catouse 已提交
1860
    window.ajustModalPosition = function(position, modal)
C
Catouse 已提交
1861
    {
C
Catouse 已提交
1862 1863
        modal = getModal(modal);
        if(modal && modal.length)
C
Catouse 已提交
1864
        {
C
Catouse 已提交
1865
            modal.modal('ajustPosition', position);
C
Catouse 已提交
1866
        }
C
Catouse 已提交
1867
    };
C
Catouse 已提交
1868

C
Catouse 已提交
1869
    $.extend(
C
Catouse 已提交
1870
    {
C
Catouse 已提交
1871 1872 1873
        closeModal         : window.closeModal,
        ajustModalPosition : window.ajustModalPosition
    });
C
Catouse 已提交
1874

C
Catouse 已提交
1875
    $(document).on('click.zui.modaltrigger.data-api', '[data-toggle="modal"]', function(e)
C
Catouse 已提交
1876
    {
C
Catouse 已提交
1877 1878 1879 1880
        var $this   = $(this);
        var href    = $this.attr('href');
        var $target = null;
        try
C
Catouse 已提交
1881
        {
C
Catouse 已提交
1882 1883 1884 1885 1886
            $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
        }catch(ex){}
        if(!$target || !$target.length)
        {
            if(!$this.data('zui.modaltrigger'))
C
Catouse 已提交
1887
            {
C
Catouse 已提交
1888
                $this.modalTrigger({show: true});
C
Catouse 已提交
1889 1890 1891
            }
            else
            {
C
Catouse 已提交
1892
                $this.trigger('.toggle.zui.modaltrigger');
C
Catouse 已提交
1893
            }
C
Catouse 已提交
1894 1895
        }
        if($this.is('a')) {e.preventDefault();}
C
Catouse 已提交
1896
    });
C
Catouse 已提交
1897
}(window.jQuery);
C
Catouse 已提交
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347

/* ========================================================================
 * Bootstrap: tooltip.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#tooltip
 * Inspired by the original jQuery.tipsy by Jason Frame
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */


+function ($) { "use strict";

  // TOOLTIP PUBLIC CLASS DEFINITION
  // ===============================

  var Tooltip = function (element, options) {
    this.type       =
    this.options    =
    this.enabled    =
    this.timeout    =
    this.hoverState =
    this.$element   = null

    this.init('tooltip', element, options)
  }

  Tooltip.DEFAULTS = {
    animation: true
  , placement: 'top'
  , selector: false
  , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  , trigger: 'hover focus'
  , title: ''
  , delay: 0
  , html: false
  , container: false
  }

  Tooltip.prototype.init = function (type, element, options) {
    this.enabled  = true
    this.type     = type
    this.$element = $(element)
    this.options  = this.getOptions(options)

    var triggers = this.options.trigger.split(' ')

    for (var i = triggers.length; i--;) {
      var trigger = triggers[i]

      if (trigger == 'click') {
        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
      } else if (trigger != 'manual') {
        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focus'
        var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'

        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
      }
    }

    this.options.selector ?
      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
      this.fixTitle()
  }

  Tooltip.prototype.getDefaults = function () {
    return Tooltip.DEFAULTS
  }

  Tooltip.prototype.getOptions = function (options) {
    options = $.extend({}, this.getDefaults(), this.$element.data(), options)

    if (options.delay && typeof options.delay == 'number') {
      options.delay = {
        show: options.delay
      , hide: options.delay
      }
    }

    return options
  }

  Tooltip.prototype.getDelegateOptions = function () {
    var options  = {}
    var defaults = this.getDefaults()

    this._options && $.each(this._options, function (key, value) {
      if (defaults[key] != value) options[key] = value
    })

    return options
  }

  Tooltip.prototype.enter = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)

    clearTimeout(self.timeout)

    self.hoverState = 'in'

    if (!self.options.delay || !self.options.delay.show) return self.show()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'in') self.show()
    }, self.options.delay.show)
  }

  Tooltip.prototype.leave = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)

    clearTimeout(self.timeout)

    self.hoverState = 'out'

    if (!self.options.delay || !self.options.delay.hide) return self.hide()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'out') self.hide()
    }, self.options.delay.hide)
  }

  Tooltip.prototype.show = function () {
    var e = $.Event('show.bs.'+ this.type)

    if (this.hasContent() && this.enabled) {
      this.$element.trigger(e)

      if (e.isDefaultPrevented()) return

      var $tip = this.tip()

      this.setContent()

      if (this.options.animation) $tip.addClass('fade')

      var placement = typeof this.options.placement == 'function' ?
        this.options.placement.call(this, $tip[0], this.$element[0]) :
        this.options.placement

      var autoToken = /\s?auto?\s?/i
      var autoPlace = autoToken.test(placement)
      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'

      $tip
        .detach()
        .css({ top: 0, left: 0, display: 'block' })
        .addClass(placement)

      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)

      var pos          = this.getPosition()
      var actualWidth  = $tip[0].offsetWidth
      var actualHeight = $tip[0].offsetHeight

      if (autoPlace) {
        var $parent = this.$element.parent()

        var orgPlacement = placement
        var docScroll    = document.documentElement.scrollTop || document.body.scrollTop
        var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()
        var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
        var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left

        placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :
                    placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :
                    placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :
                    placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :
                    placement

        $tip
          .removeClass(orgPlacement)
          .addClass(placement)
      }

      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)

      this.applyPlacement(calculatedOffset, placement)
      this.$element.trigger('shown.bs.' + this.type)
    }
  }

  Tooltip.prototype.applyPlacement = function(offset, placement) {
    var replace
    var $tip   = this.tip()
    var width  = $tip[0].offsetWidth
    var height = $tip[0].offsetHeight

    // manually read margins because getBoundingClientRect includes difference
    var marginTop = parseInt($tip.css('margin-top'), 10)
    var marginLeft = parseInt($tip.css('margin-left'), 10)

    // we must check for NaN for ie 8/9
    if (isNaN(marginTop))  marginTop  = 0
    if (isNaN(marginLeft)) marginLeft = 0

    offset.top  = offset.top  + marginTop
    offset.left = offset.left + marginLeft

    $tip
      .offset(offset)
      .addClass('in')

    // check to see if placing tip in new offset caused the tip to resize itself
    var actualWidth  = $tip[0].offsetWidth
    var actualHeight = $tip[0].offsetHeight

    if (placement == 'top' && actualHeight != height) {
      replace = true
      offset.top = offset.top + height - actualHeight
    }

    if (/bottom|top/.test(placement)) {
      var delta = 0

      if (offset.left < 0) {
        delta       = offset.left * -2
        offset.left = 0

        $tip.offset(offset)

        actualWidth  = $tip[0].offsetWidth
        actualHeight = $tip[0].offsetHeight
      }

      this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
    } else {
      this.replaceArrow(actualHeight - height, actualHeight, 'top')
    }

    if (replace) $tip.offset(offset)
  }

  Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
    this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  }

  Tooltip.prototype.setContent = function () {
    var $tip  = this.tip()
    var title = this.getTitle()

    $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
    $tip.removeClass('fade in top bottom left right')
  }

  Tooltip.prototype.hide = function () {
    var that = this
    var $tip = this.tip()
    var e    = $.Event('hide.bs.' + this.type)

    function complete() {
      if (that.hoverState != 'in') $tip.detach()
    }

    this.$element.trigger(e)

    if (e.isDefaultPrevented()) return

    $tip.removeClass('in')

    $.support.transition && this.$tip.hasClass('fade') ?
      $tip
        .one($.support.transition.end, complete)
        .emulateTransitionEnd(150) :
      complete()

    this.$element.trigger('hidden.bs.' + this.type)

    return this
  }

  Tooltip.prototype.fixTitle = function () {
    var $e = this.$element
    if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
    }
  }

  Tooltip.prototype.hasContent = function () {
    return this.getTitle()
  }

  Tooltip.prototype.getPosition = function () {
    var el = this.$element[0]
    return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
      width: el.offsetWidth
    , height: el.offsetHeight
    }, this.$element.offset())
  }

  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
  }

  Tooltip.prototype.getTitle = function () {
    var title
    var $e = this.$element
    var o  = this.options

    title = $e.attr('data-original-title')
      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)

    return title
  }

  Tooltip.prototype.tip = function () {
    return this.$tip = this.$tip || $(this.options.template)
  }

  Tooltip.prototype.arrow = function () {
    return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
  }

  Tooltip.prototype.validate = function () {
    if (!this.$element[0].parentNode) {
      this.hide()
      this.$element = null
      this.options  = null
    }
  }

  Tooltip.prototype.enable = function () {
    this.enabled = true
  }

  Tooltip.prototype.disable = function () {
    this.enabled = false
  }

  Tooltip.prototype.toggleEnabled = function () {
    this.enabled = !this.enabled
  }

  Tooltip.prototype.toggle = function (e) {
    var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
    self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  }

  Tooltip.prototype.destroy = function () {
    this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
  }


  // TOOLTIP PLUGIN DEFINITION
  // =========================

  var old = $.fn.tooltip

  $.fn.tooltip = function (option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.tooltip')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.tooltip.Constructor = Tooltip


  // TOOLTIP NO CONFLICT
  // ===================

  $.fn.tooltip.noConflict = function () {
    $.fn.tooltip = old
    return this
  }

}(window.jQuery);

/* ========================================================================
 * Bootstrap: popover.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#popovers
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */


+function ($) { "use strict";

  // POPOVER PUBLIC CLASS DEFINITION
  // ===============================

  var Popover = function (element, options) {
    this.init('popover', element, options)
  }

  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')

  Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
    placement: 'right'
  , trigger: 'click'
  , content: ''
  , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  })


  // NOTE: POPOVER EXTENDS tooltip.js
  // ================================

  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)

  Popover.prototype.constructor = Popover

  Popover.prototype.getDefaults = function () {
    return Popover.DEFAULTS
  }

  Popover.prototype.setContent = function () {
    var $tip    = this.tip()
    var target = this.getTarget()

    if(target)
    {
      if(target.find('.arrow').length < 1)
        $tip.addClass('no-arrow')
      $tip.html(target.html())
      return
    }

C
Catouse 已提交
2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505
    
    var title   = this.getTitle()
    var content = this.getContent()

    $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
    $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)

    $tip.removeClass('fade top bottom left right in')

    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
    // this manually by checking the contents.
    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  }

  Popover.prototype.hasContent = function () {
    return this.getTarget() || this.getTitle() || this.getContent()
  }

  Popover.prototype.getContent = function () {
    var $e = this.$element
    var o  = this.options

    return $e.attr('data-content')
      || (typeof o.content == 'function' ?
            o.content.call($e[0]) :
            o.content)
  }

  Popover.prototype.getTarget = function () {
    var $e = this.$element
    var o  = this.options

    var target = $e.attr('data-target')
      || (typeof o.target == 'function' ?
            o.target.call($e[0]) :
            o.target)
    return (target && true) ? ( target == '$next' ? $e.next('.popover') : $(target)) : false
  }

  Popover.prototype.arrow = function () {
    return this.$arrow = this.$arrow || this.tip().find('.arrow')
  }

  Popover.prototype.tip = function () {
    if (!this.$tip) this.$tip = $(this.options.template)
    return this.$tip
  }


  // POPOVER PLUGIN DEFINITION
  // =========================

  var old = $.fn.popover

  $.fn.popover = function (option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.popover')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.popover.Constructor = Popover


  // POPOVER NO CONFLICT
  // ===================

  $.fn.popover.noConflict = function () {
    $.fn.popover = old
    return this
  }

}(window.jQuery);

/* ========================================================================
 * Bootstrap: dropdown.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#dropdowns
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */


+function ($) { "use strict";

  // DROPDOWN CLASS DEFINITION
  // =========================

  var backdrop = '.dropdown-backdrop'
  var toggle   = '[data-toggle=dropdown]'
  var Dropdown = function (element) {
    var $el = $(element).on('click.bs.dropdown', this.toggle)
  }

  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)

    if ($this.is('.disabled, :disabled')) return

    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')

    clearMenus()

    if (!isActive) {
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
        // if mobile we we use a backdrop because click events don't delegate
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
      }

      $parent.trigger(e = $.Event('show.bs.dropdown'))

      if (e.isDefaultPrevented()) return

      $parent
        .toggleClass('open')
        .trigger('shown.bs.dropdown')

      $this.focus()
    }

    return false
  }

  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27)/.test(e.keyCode)) return

    var $this = $(this)

    e.preventDefault()
    e.stopPropagation()

    if ($this.is('.disabled, :disabled')) return

    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')

    if (!isActive || (isActive && e.keyCode == 27)) {
      if (e.which == 27) $parent.find(toggle).focus()
      return $this.click()
    }

    var $items = $('[role=menu] li:not(.divider):visible a', $parent)
C
Catouse 已提交
2506

C
Catouse 已提交
2507
    if (!$items.length) return
C
Catouse 已提交
2508

C
Catouse 已提交
2509
    var index = $items.index($items.filter(':focus'))
C
Catouse 已提交
2510

C
Catouse 已提交
2511 2512 2513
    if (e.keyCode == 38 && index > 0)                 index--                        // up
    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
    if (!~index)                                      index=0
C
Catouse 已提交
2514

C
Catouse 已提交
2515
    $items.eq(index).focus()
C
Catouse 已提交
2516 2517
  }

C
Catouse 已提交
2518 2519 2520 2521 2522 2523 2524 2525 2526
  function clearMenus() {
    $(backdrop).remove()
    $(toggle).each(function (e) {
      var $parent = getParent($(this))
      if (!$parent.hasClass('open')) return
      $parent.trigger(e = $.Event('hide.bs.dropdown'))
      if (e.isDefaultPrevented()) return
      $parent.removeClass('open').trigger('hidden.bs.dropdown')
    })
C
Catouse 已提交
2527 2528
  }

C
Catouse 已提交
2529 2530
  function getParent($this) {
    var selector = $this.attr('data-target')
C
Catouse 已提交
2531

C
Catouse 已提交
2532 2533 2534 2535
    if (!selector) {
      selector = $this.attr('href')
      selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
    }
C
Catouse 已提交
2536

C
Catouse 已提交
2537
    var $parent = selector && $(selector)
C
Catouse 已提交
2538

C
Catouse 已提交
2539
    return $parent && $parent.length ? $parent : $this.parent()
C
Catouse 已提交
2540 2541 2542
  }


C
Catouse 已提交
2543 2544
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
C
Catouse 已提交
2545

C
Catouse 已提交
2546
  var old = $.fn.dropdown
C
Catouse 已提交
2547

C
Catouse 已提交
2548
  $.fn.dropdown = function (option) {
C
Catouse 已提交
2549
    return this.each(function () {
C
Catouse 已提交
2550 2551
      var $this = $(this)
      var data  = $this.data('dropdown')
C
Catouse 已提交
2552

C
Catouse 已提交
2553 2554
      if (!data) $this.data('dropdown', (data = new Dropdown(this)))
      if (typeof option == 'string') data[option].call($this)
C
Catouse 已提交
2555 2556 2557
    })
  }

C
Catouse 已提交
2558
  $.fn.dropdown.Constructor = Dropdown
C
Catouse 已提交
2559 2560


C
Catouse 已提交
2561 2562
  // DROPDOWN NO CONFLICT
  // ====================
C
Catouse 已提交
2563

C
Catouse 已提交
2564 2565
  $.fn.dropdown.noConflict = function () {
    $.fn.dropdown = old
C
Catouse 已提交
2566 2567 2568
    return this
  }

C
Catouse 已提交
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578

  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

  $(document)
    .on('click.bs.dropdown.data-api', clearMenus)
    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
    .on('click.bs.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
    .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)

C
Catouse 已提交
2579 2580 2581
}(window.jQuery);

/* ========================================================================
C
Catouse 已提交
2582 2583
 * Bootstrap: carousel.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#carousel
C
Catouse 已提交
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602
 * ========================================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */


+function ($) { "use strict";

C
Catouse 已提交
2603 2604
  // CAROUSEL CLASS DEFINITION
  // =========================
C
Catouse 已提交
2605

C
Catouse 已提交
2606 2607 2608 2609 2610 2611 2612 2613 2614
  var Carousel = function (element, options) {
    this.$element    = $(element)
    this.$indicators = this.$element.find('.carousel-indicators')
    this.options     = options
    this.paused      =
    this.sliding     =
    this.interval    =
    this.$active     =
    this.$items      = null
C
Catouse 已提交
2615

C
Catouse 已提交
2616 2617 2618 2619
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }
C
Catouse 已提交
2620

C
Catouse 已提交
2621 2622 2623 2624 2625 2626
  Carousel.DEFAULTS = {
    interval: 5000
  , pause: 'hover'
  , wrap: true
  , touchable: true
  }
C
Catouse 已提交
2627

C
Catouse 已提交
2628 2629 2630
  Carousel.prototype.touchable = function()
  {
      if(!this.options.touchable) return;
C
Catouse 已提交
2631

C
Catouse 已提交
2632 2633
      this.$element.on('touchstart touchmove touchend', touch);
      // this.$element.on('touchstart touchmove touchend', $.proxy(touch,this));
C
Catouse 已提交
2634

C
Catouse 已提交
2635
      // $('.carousel').on('touchstart touchmove touchend',  touch);
C
Catouse 已提交
2636

C
Catouse 已提交
2637
      var touchStartX, touchStartY;
C
Catouse 已提交
2638

C
Catouse 已提交
2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670
      /* listen the touch event */
      function touch(event)
      {
          var event = event || window.event;
          if(event.originalEvent) event = event.originalEvent;
          var carousel = $(this);

          switch(event.type)
          {
              case "touchstart":
                  touchStartX = event.touches[0].pageX;
                  touchStartY = event.touches[0].pageY;
                  break;
              case "touchend":
                  var distanceX = event.changedTouches[0].pageX - touchStartX;
                  var distanceY = event.changedTouches[0].pageY - touchStartY;
                  if(Math.abs(distanceX) > Math.abs(distanceY))
                  {
                      handleCarousel(carousel, distanceX);
                      if(Math.abs(distanceX) > 10)
                      {
                          event.preventDefault();
                      }
                  }
                  else
                  {
                      var $w = $(window);
                      $('body,html').animate({scrollTop:$w.scrollTop() - distanceY},400)
                  }
                  break;
          }
      }
C
Catouse 已提交
2671

C
Catouse 已提交
2672 2673 2674 2675 2676
      function handleCarousel(carousel, distance)
      {
          if(distance > 10) carousel.find('.left.carousel-control').click();
          if(distance < -10) carousel.find('.right.carousel-control').click();
      }
C
Catouse 已提交
2677 2678
  }

C
Catouse 已提交
2679 2680
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
C
Catouse 已提交
2681

C
Catouse 已提交
2682
    this.interval && clearInterval(this.interval)
C
Catouse 已提交
2683

C
Catouse 已提交
2684 2685 2686
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
C
Catouse 已提交
2687

C
Catouse 已提交
2688 2689
    return this
  }
C
Catouse 已提交
2690

C
Catouse 已提交
2691 2692 2693
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
    this.$items  = this.$active.parent().children()
C
Catouse 已提交
2694

C
Catouse 已提交
2695 2696
    return this.$items.index(this.$active)
  }
C
Catouse 已提交
2697

C
Catouse 已提交
2698 2699 2700
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
C
Catouse 已提交
2701

C
Catouse 已提交
2702 2703 2704 2705 2706 2707
    if (pos > (this.$items.length - 1) || pos < 0) return

    if (this.sliding)       return this.$element.one('slid', function () { that.to(pos) })
    if (activeIndex == pos) return this.pause().cycle()

    return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
C
Catouse 已提交
2708 2709
  }

C
Catouse 已提交
2710 2711
  Carousel.prototype.pause = function (e) {
    e || (this.paused = true)
C
Catouse 已提交
2712

C
Catouse 已提交
2713 2714 2715 2716
    if (this.$element.find('.next, .prev').length && $.support.transition.end) {
      this.$element.trigger($.support.transition.end)
      this.cycle(true)
    }
C
Catouse 已提交
2717

C
Catouse 已提交
2718
    this.interval = clearInterval(this.interval)
C
Catouse 已提交
2719

C
Catouse 已提交
2720 2721
    return this
  }
C
Catouse 已提交
2722

C
Catouse 已提交
2723 2724 2725
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
C
Catouse 已提交
2726 2727
  }

C
Catouse 已提交
2728 2729 2730 2731
  Carousel.prototype.prev = function () {
    if (this.sliding) return
    return this.slide('prev')
  }
C
Catouse 已提交
2732

C
Catouse 已提交
2733 2734 2735 2736 2737 2738 2739
  Carousel.prototype.slide = function (type, next) {
    var $active   = this.$element.find('.item.active')
    var $next     = next || $active[type]()
    var isCycling = this.interval
    var direction = type == 'next' ? 'left' : 'right'
    var fallback  = type == 'next' ? 'first' : 'last'
    var that      = this
C
Catouse 已提交
2740

C
Catouse 已提交
2741 2742 2743 2744
    if (!$next.length) {
      if (!this.options.wrap) return
      $next = this.$element.find('.item')[fallback]()
    }
C
Catouse 已提交
2745

C
Catouse 已提交
2746
    this.sliding = true
C
Catouse 已提交
2747

C
Catouse 已提交
2748
    isCycling && this.pause()
C
Catouse 已提交
2749

C
Catouse 已提交
2750
    var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
C
Catouse 已提交
2751

C
Catouse 已提交
2752
    if ($next.hasClass('active')) return
C
Catouse 已提交
2753

C
Catouse 已提交
2754 2755 2756 2757 2758 2759 2760
    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
      this.$element.one('slid', function () {
        var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
        $nextIndicator && $nextIndicator.addClass('active')
      })
    }
C
Catouse 已提交
2761

C
Catouse 已提交
2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784
    if ($.support.transition && this.$element.hasClass('slide')) {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $next.addClass(type)
      $next[0].offsetWidth // force reflow
      $active.addClass(direction)
      $next.addClass(direction)
      $active
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
          setTimeout(function () { that.$element.trigger('slid') }, 0)
        })
        .emulateTransitionEnd(600)
    } else {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
      this.$element.trigger('slid')
    }
C
Catouse 已提交
2785

C
Catouse 已提交
2786
    isCycling && this.cycle()
C
Catouse 已提交
2787

C
Catouse 已提交
2788 2789
    return this
  }
C
Catouse 已提交
2790 2791


C
Catouse 已提交
2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802
  // CAROUSEL PLUGIN DEFINITION
  // ==========================

  var old = $.fn.carousel

  $.fn.carousel = function (option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.carousel')
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
      var action  = typeof option == 'string' ? option : options.slide
C
Catouse 已提交
2803

C
Catouse 已提交
2804 2805 2806 2807
      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
      if (typeof option == 'number') data.to(option)
      else if (action) data[action]()
      else if (options.interval) data.pause().cycle()
C
Catouse 已提交
2808

C
Catouse 已提交
2809 2810 2811
      if(options.touchable) data.touchable()
    })
  }
C
Catouse 已提交
2812

C
Catouse 已提交
2813
  $.fn.carousel.Constructor = Carousel
C
Catouse 已提交
2814 2815


C
Catouse 已提交
2816 2817
  // CAROUSEL NO CONFLICT
  // ====================
C
Catouse 已提交
2818

C
Catouse 已提交
2819 2820 2821 2822
  $.fn.carousel.noConflict = function () {
    $.fn.carousel = old
    return this
  }
C
Catouse 已提交
2823 2824


C
Catouse 已提交
2825 2826
  // CAROUSEL DATA-API
  // =================
C
Catouse 已提交
2827

C
Catouse 已提交
2828 2829 2830 2831 2832 2833
  $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
    var $this   = $(this), href
    var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
    var options = $.extend({}, $target.data(), $this.data())
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false
C
Catouse 已提交
2834

C
Catouse 已提交
2835
    $target.carousel(options)
C
Catouse 已提交
2836

C
Catouse 已提交
2837 2838 2839
    if (slideIndex = $this.attr('data-slide-to')) {
      $target.data('bs.carousel').to(slideIndex)
    }
C
Catouse 已提交
2840

C
Catouse 已提交
2841 2842
    e.preventDefault()
  })
C
Catouse 已提交
2843

C
Catouse 已提交
2844 2845 2846 2847 2848 2849
  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      $carousel.carousel($carousel.data())
    })
  })
C
Catouse 已提交
2850

C
Catouse 已提交
2851
}(window.jQuery);