2 * Jasny Bootstrap v3.1.3 (http://jasny.github.io/bootstrap)
3 * Copyright 2012-2014 Arnold Daniels
4 * Licensed under Apache-2.0 (https://github.com/jasny/bootstrap/blob/master/LICENSE)
7 if (typeof jQuery === 'undefined') { throw new Error('Jasny Bootstrap\'s JavaScript requires jQuery') }
9 /* ========================================================================
10 * Bootstrap: transition.js v3.1.3
11 * http://getbootstrap.com/javascript/#transitions
12 * ========================================================================
13 * Copyright 2011-2014 Twitter, Inc.
14 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15 * ======================================================================== */
21 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
22 // ============================================================
24 function transitionEnd() {
25 var el = document.createElement('bootstrap')
27 var transEndEventNames = {
28 WebkitTransition : 'webkitTransitionEnd',
29 MozTransition : 'transitionend',
30 OTransition : 'oTransitionEnd otransitionend',
31 transition : 'transitionend'
34 for (var name in transEndEventNames) {
35 if (el.style[name] !== undefined) {
36 return { end: transEndEventNames[name] }
40 return false // explicit for ie8 ( ._.)
43 if ($.support.transition !== undefined) return // Prevent conflict with Twitter Bootstrap
45 // http://blog.alexmaccaw.com/css-transitions
46 $.fn.emulateTransitionEnd = function (duration) {
47 var called = false, $el = this
48 $(this).one($.support.transition.end, function () { called = true })
49 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
50 setTimeout(callback, duration)
55 $.support.transition = transitionEnd()
60 /* ========================================================================
61 * Bootstrap: offcanvas.js v3.1.3
62 * http://jasny.github.io/bootstrap/javascript/#offcanvas
63 * ========================================================================
64 * Copyright 2013-2014 Arnold Daniels
66 * Licensed under the Apache License, Version 2.0 (the "License")
67 * you may not use this file except in compliance with the License.
68 * You may obtain a copy of the License at
70 * http://www.apache.org/licenses/LICENSE-2.0
72 * Unless required by applicable law or agreed to in writing, software
73 * distributed under the License is distributed on an "AS IS" BASIS,
74 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75 * See the License for the specific language governing permissions and
76 * limitations under the License.
77 * ======================================================================== */
79 +function ($) { "use strict";
81 // OFFCANVAS PUBLIC CLASS DEFINITION
82 // =================================
84 var OffCanvas = function (element, options) {
85 this.$element = $(element)
86 this.options = $.extend({}, OffCanvas.DEFAULTS, options)
90 if (this.options.recalc) {
92 $(window).on('resize', $.proxy(this.recalc, this))
95 if (this.options.autohide)
96 $(document).on('click', $.proxy(this.autohide, this))
98 if (this.options.toggle) this.toggle()
100 if (this.options.disablescrolling) {
101 this.options.disableScrolling = this.options.disablescrolling
102 delete this.options.disablescrolling
106 OffCanvas.DEFAULTS = {
111 disableScrolling: false
114 OffCanvas.prototype.offset = function () {
115 switch (this.placement) {
117 case 'right': return this.$element.outerWidth()
119 case 'bottom': return this.$element.outerHeight()
123 OffCanvas.prototype.calcPlacement = function () {
124 if (this.options.placement !== 'auto') {
125 this.placement = this.options.placement
129 if (!this.$element.hasClass('in')) {
130 this.$element.css('visiblity', 'hidden !important').addClass('in')
133 var horizontal = $(window).width() / this.$element.width()
134 var vertical = $(window).height() / this.$element.height()
136 var element = this.$element
138 if (element.css(b) === 'auto') return a
139 if (element.css(a) === 'auto') return b
141 var size_a = parseInt(element.css(a), 10)
142 var size_b = parseInt(element.css(b), 10)
144 return size_a > size_b ? b : a
147 this.placement = horizontal >= vertical ? ab('left', 'right') : ab('top', 'bottom')
149 if (this.$element.css('visibility') === 'hidden !important') {
150 this.$element.removeClass('in').css('visiblity', '')
154 OffCanvas.prototype.opposite = function (placement) {
156 case 'top': return 'bottom'
157 case 'left': return 'right'
158 case 'bottom': return 'top'
159 case 'right': return 'left'
163 OffCanvas.prototype.getCanvasElements = function() {
164 // Return a set containing the canvas plus all fixed elements
165 var canvas = this.options.canvas ? $(this.options.canvas) : this.$element
167 var fixed_elements = canvas.find('*').filter(function() {
168 return $(this).css('position') === 'fixed'
169 }).not(this.options.exclude)
171 return canvas.add(fixed_elements)
174 OffCanvas.prototype.slide = function (elements, offset, callback) {
175 // Use jQuery animation if CSS transitions aren't supported
176 if (!$.support.transition) {
178 anim[this.placement] = "+=" + offset
179 return elements.animate(anim, 350, callback)
182 var placement = this.placement
183 var opposite = this.opposite(placement)
185 elements.each(function() {
186 if ($(this).css(placement) !== 'auto')
187 $(this).css(placement, (parseInt($(this).css(placement), 10) || 0) + offset)
189 if ($(this).css(opposite) !== 'auto')
190 $(this).css(opposite, (parseInt($(this).css(opposite), 10) || 0) - offset)
194 .one($.support.transition.end, callback)
195 .emulateTransitionEnd(350)
198 OffCanvas.prototype.disableScrolling = function() {
199 var bodyWidth = $('body').width()
200 var prop = 'padding-' + this.opposite(this.placement)
202 if ($('body').data('offcanvas-style') === undefined) {
203 $('body').data('offcanvas-style', $('body').attr('style') || '')
206 $('body').css('overflow', 'hidden')
208 if ($('body').width() > bodyWidth) {
209 var padding = parseInt($('body').css(prop), 10) + $('body').width() - bodyWidth
211 setTimeout(function() {
212 $('body').css(prop, padding)
217 OffCanvas.prototype.show = function () {
218 if (this.state) return
220 var startEvent = $.Event('show.bs.offcanvas')
221 this.$element.trigger(startEvent)
222 if (startEvent.isDefaultPrevented()) return
224 this.state = 'slide-in'
225 this.calcPlacement();
227 var elements = this.getCanvasElements()
228 var placement = this.placement
229 var opposite = this.opposite(placement)
230 var offset = this.offset()
232 if (elements.index(this.$element) !== -1) {
233 $(this.$element).data('offcanvas-style', $(this.$element).attr('style') || '')
234 this.$element.css(placement, -1 * offset)
235 this.$element.css(placement); // Workaround: Need to get the CSS property for it to be applied before the next line of code
238 elements.addClass('canvas-sliding').each(function() {
239 if ($(this).data('offcanvas-style') === undefined) $(this).data('offcanvas-style', $(this).attr('style') || '')
240 if ($(this).css('position') === 'static') $(this).css('position', 'relative')
241 if (($(this).css(placement) === 'auto' || $(this).css(placement) === '0px') &&
242 ($(this).css(opposite) === 'auto' || $(this).css(opposite) === '0px')) {
243 $(this).css(placement, 0)
247 if (this.options.disableScrolling) this.disableScrolling()
249 var complete = function () {
250 if (this.state != 'slide-in') return
254 elements.removeClass('canvas-sliding').addClass('canvas-slid')
255 this.$element.trigger('shown.bs.offcanvas')
258 setTimeout($.proxy(function() {
259 this.$element.addClass('in')
260 this.slide(elements, offset, $.proxy(complete, this))
264 OffCanvas.prototype.hide = function (fast) {
265 if (this.state !== 'slid') return
267 var startEvent = $.Event('hide.bs.offcanvas')
268 this.$element.trigger(startEvent)
269 if (startEvent.isDefaultPrevented()) return
271 this.state = 'slide-out'
273 var elements = $('.canvas-slid')
274 var placement = this.placement
275 var offset = -1 * this.offset()
277 var complete = function () {
278 if (this.state != 'slide-out') return
281 this.placement = null
283 this.$element.removeClass('in')
285 elements.removeClass('canvas-sliding')
286 elements.add(this.$element).add('body').each(function() {
287 $(this).attr('style', $(this).data('offcanvas-style')).removeData('offcanvas-style')
290 this.$element.trigger('hidden.bs.offcanvas')
293 elements.removeClass('canvas-slid').addClass('canvas-sliding')
295 setTimeout($.proxy(function() {
296 this.slide(elements, offset, $.proxy(complete, this))
300 OffCanvas.prototype.toggle = function () {
301 if (this.state === 'slide-in' || this.state === 'slide-out') return
302 this[this.state === 'slid' ? 'hide' : 'show']()
305 OffCanvas.prototype.calcClone = function() {
306 this.$calcClone = this.$element.clone()
308 .addClass('offcanvas-clone').removeClass('in')
312 OffCanvas.prototype.recalc = function () {
313 if (this.$calcClone.css('display') === 'none' || (this.state !== 'slid' && this.state !== 'slide-in')) return
316 this.placement = null
317 var elements = this.getCanvasElements()
319 this.$element.removeClass('in')
321 elements.removeClass('canvas-slid')
322 elements.add(this.$element).add('body').each(function() {
323 $(this).attr('style', $(this).data('offcanvas-style')).removeData('offcanvas-style')
327 OffCanvas.prototype.autohide = function (e) {
328 if ($(e.target).closest(this.$element).length === 0) this.hide()
331 // OFFCANVAS PLUGIN DEFINITION
332 // ==========================
334 var old = $.fn.offcanvas
336 $.fn.offcanvas = function (option) {
337 return this.each(function () {
339 var data = $this.data('bs.offcanvas')
340 var options = $.extend({}, OffCanvas.DEFAULTS, $this.data(), typeof option === 'object' && option)
342 if (!data) $this.data('bs.offcanvas', (data = new OffCanvas(this, options)))
343 if (typeof option === 'string') data[option]()
347 $.fn.offcanvas.Constructor = OffCanvas
350 // OFFCANVAS NO CONFLICT
351 // ====================
353 $.fn.offcanvas.noConflict = function () {
359 // OFFCANVAS DATA-API
362 $(document).on('click.bs.offcanvas.data-api', '[data-toggle=offcanvas]', function (e) {
363 var $this = $(this), href
364 var target = $this.attr('data-target')
365 || e.preventDefault()
366 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
367 var $canvas = $(target)
368 var data = $canvas.data('bs.offcanvas')
369 var option = data ? 'toggle' : $this.data()
373 if (data) data.toggle()
374 else $canvas.offcanvas(option)
379 /* ============================================================
380 * Bootstrap: rowlink.js v3.1.3
381 * http://jasny.github.io/bootstrap/javascript/#rowlink
382 * ============================================================
383 * Copyright 2012-2014 Arnold Daniels
385 * Licensed under the Apache License, Version 2.0 (the "License");
386 * you may not use this file except in compliance with the License.
387 * You may obtain a copy of the License at
389 * http://www.apache.org/licenses/LICENSE-2.0
391 * Unless required by applicable law or agreed to in writing, software
392 * distributed under the License is distributed on an "AS IS" BASIS,
393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
394 * See the License for the specific language governing permissions and
395 * limitations under the License.
396 * ============================================================ */
398 +function ($) { "use strict";
400 var Rowlink = function (element, options) {
401 this.$element = $(element)
402 this.options = $.extend({}, Rowlink.DEFAULTS, options)
404 this.$element.on('click.bs.rowlink', 'td:not(.rowlink-skip)', $.proxy(this.click, this))
411 Rowlink.prototype.click = function(e) {
412 var target = $(e.currentTarget).closest('tr').find(this.options.target)[0]
413 if ($(e.target)[0] === target) return
419 } else if (document.createEvent) {
420 var evt = document.createEvent("MouseEvents");
421 evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
422 target.dispatchEvent(evt);
427 // ROWLINK PLUGIN DEFINITION
428 // ===========================
430 var old = $.fn.rowlink
432 $.fn.rowlink = function (options) {
433 return this.each(function () {
435 var data = $this.data('bs.rowlink')
436 if (!data) $this.data('bs.rowlink', (data = new Rowlink(this, options)))
440 $.fn.rowlink.Constructor = Rowlink
443 // ROWLINK NO CONFLICT
444 // ====================
446 $.fn.rowlink.noConflict = function () {
453 // ==================
455 $(document).on('click.bs.rowlink.data-api', '[data-link="row"]', function (e) {
456 if ($(e.target).closest('.rowlink-skip').length !== 0) return
459 if ($this.data('bs.rowlink')) return
460 $this.rowlink($this.data())
461 $(e.target).trigger('click.bs.rowlink')
466 /* ===========================================================
467 * Bootstrap: inputmask.js v3.1.0
468 * http://jasny.github.io/bootstrap/javascript/#inputmask
470 * Based on Masked Input plugin by Josh Bush (digitalbush.com)
471 * ===========================================================
472 * Copyright 2012-2014 Arnold Daniels
474 * Licensed under the Apache License, Version 2.0 (the "License")
475 * you may not use this file except in compliance with the License.
476 * You may obtain a copy of the License at
478 * http://www.apache.org/licenses/LICENSE-2.0
480 * Unless required by applicable law or agreed to in writing, software
481 * distributed under the License is distributed on an "AS IS" BASIS,
482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
483 * See the License for the specific language governing permissions and
484 * limitations under the License.
485 * ========================================================== */
487 +function ($) { "use strict";
489 var isIphone = (window.orientation !== undefined)
490 var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
491 var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
493 // INPUTMASK PUBLIC CLASS DEFINITION
494 // =================================
496 var Inputmask = function (element, options) {
497 if (isAndroid) return // No support because caret positioning doesn't work on Android
499 this.$element = $(element)
500 this.options = $.extend({}, Inputmask.DEFAULTS, options)
501 this.mask = String(this.options.mask)
506 this.checkVal() //Perform initial check for existing values
509 Inputmask.DEFAULTS = {
520 Inputmask.prototype.init = function() {
521 var defs = this.options.definitions
522 var len = this.mask.length
525 this.partialPosition = this.mask.length
526 this.firstNonMaskPos = null
528 $.each(this.mask.split(""), $.proxy(function(i, c) {
531 this.partialPosition = i
532 } else if (defs[c]) {
533 this.tests.push(new RegExp(defs[c]))
534 if (this.firstNonMaskPos === null)
535 this.firstNonMaskPos = this.tests.length - 1
537 this.tests.push(null)
541 this.buffer = $.map(this.mask.split(""), $.proxy(function(c, i) {
542 if (c != '?') return defs[c] ? this.options.placeholder : c
545 this.focusText = this.$element.val()
547 this.$element.data("rawMaskFn", $.proxy(function() {
548 return $.map(this.buffer, function(c, i) {
549 return this.tests[i] && c != this.options.placeholder ? c : null
554 Inputmask.prototype.listen = function() {
555 if (this.$element.attr("readonly")) return
557 var pasteEventName = (isIE ? 'paste' : 'input') + ".mask"
560 .on("unmask.bs.inputmask", $.proxy(this.unmask, this))
562 .on("focus.bs.inputmask", $.proxy(this.focusEvent, this))
563 .on("blur.bs.inputmask", $.proxy(this.blurEvent, this))
565 .on("keydown.bs.inputmask", $.proxy(this.keydownEvent, this))
566 .on("keypress.bs.inputmask", $.proxy(this.keypressEvent, this))
568 .on(pasteEventName, $.proxy(this.pasteEvent, this))
571 //Helper Function for Caret positioning
572 Inputmask.prototype.caret = function(begin, end) {
573 if (this.$element.length === 0) return
574 if (typeof begin == 'number') {
575 end = (typeof end == 'number') ? end : begin
576 return this.$element.each(function() {
577 if (this.setSelectionRange) {
578 this.setSelectionRange(begin, end)
579 } else if (this.createTextRange) {
580 var range = this.createTextRange()
582 range.moveEnd('character', end)
583 range.moveStart('character', begin)
588 if (this.$element[0].setSelectionRange) {
589 begin = this.$element[0].selectionStart
590 end = this.$element[0].selectionEnd
591 } else if (document.selection && document.selection.createRange) {
592 var range = document.selection.createRange()
593 begin = 0 - range.duplicate().moveStart('character', -100000)
594 end = begin + range.text.length
603 Inputmask.prototype.seekNext = function(pos) {
604 var len = this.mask.length
605 while (++pos <= len && !this.tests[pos]);
610 Inputmask.prototype.seekPrev = function(pos) {
611 while (--pos >= 0 && !this.tests[pos]);
616 Inputmask.prototype.shiftL = function(begin,end) {
617 var len = this.mask.length
619 if (begin < 0) return
621 for (var i = begin, j = this.seekNext(end); i < len; i++) {
623 if (j < len && this.tests[i].test(this.buffer[j])) {
624 this.buffer[i] = this.buffer[j]
625 this.buffer[j] = this.options.placeholder
632 this.caret(Math.max(this.firstNonMaskPos, begin))
635 Inputmask.prototype.shiftR = function(pos) {
636 var len = this.mask.length
638 for (var i = pos, c = this.options.placeholder; i < len; i++) {
640 var j = this.seekNext(i)
641 var t = this.buffer[i]
643 if (j < len && this.tests[j].test(t))
651 Inputmask.prototype.unmask = function() {
654 .removeData("inputmask")
657 Inputmask.prototype.focusEvent = function() {
658 this.focusText = this.$element.val()
659 var len = this.mask.length
660 var pos = this.checkVal()
664 var moveCaret = function() {
672 setTimeout(moveCaret, 50)
675 Inputmask.prototype.blurEvent = function() {
677 if (this.$element.val() !== this.focusText)
678 this.$element.trigger('change')
681 Inputmask.prototype.keydownEvent = function(e) {
684 //backspace, delete, and escape get special treatment
685 if (k == 8 || k == 46 || (isIphone && k == 127)) {
686 var pos = this.caret(),
690 if (end - begin === 0) {
691 begin = k != 46 ? this.seekPrev(begin) : (end = this.seekNext(begin - 1))
692 end = k == 46 ? this.seekNext(end) : end
694 this.clearBuffer(begin, end)
695 this.shiftL(begin, end - 1)
698 } else if (k == 27) {//escape
699 this.$element.val(this.focusText)
700 this.caret(0, this.checkVal())
705 Inputmask.prototype.keypressEvent = function(e) {
706 var len = this.mask.length
711 if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
714 if (pos.end - pos.begin !== 0) {
715 this.clearBuffer(pos.begin, pos.end)
716 this.shiftL(pos.begin, pos.end - 1)
719 var p = this.seekNext(pos.begin - 1)
721 var c = String.fromCharCode(k)
722 if (this.tests[p].test(c)) {
726 var next = this.seekNext(p)
734 Inputmask.prototype.pasteEvent = function() {
737 setTimeout(function() {
738 that.caret(that.checkVal(true))
742 Inputmask.prototype.clearBuffer = function(start, end) {
743 var len = this.mask.length
745 for (var i = start; i < end && i < len; i++) {
747 this.buffer[i] = this.options.placeholder
751 Inputmask.prototype.writeBuffer = function() {
752 return this.$element.val(this.buffer.join('')).val()
755 Inputmask.prototype.checkVal = function(allow) {
756 var len = this.mask.length
757 //try to place characters where they belong
758 var test = this.$element.val()
761 for (var i = 0, pos = 0; i < len; i++) {
763 this.buffer[i] = this.options.placeholder
764 while (pos++ < test.length) {
765 var c = test.charAt(pos - 1)
766 if (this.tests[i].test(c)) {
772 if (pos > test.length)
774 } else if (this.buffer[i] == test.charAt(pos) && i != this.partialPosition) {
779 if (!allow && lastMatch + 1 < this.partialPosition) {
780 this.$element.val("")
781 this.clearBuffer(0, len)
782 } else if (allow || lastMatch + 1 >= this.partialPosition) {
784 if (!allow) this.$element.val(this.$element.val().substring(0, lastMatch + 1))
786 return (this.partialPosition ? i : this.firstNonMaskPos)
790 // INPUTMASK PLUGIN DEFINITION
791 // ===========================
793 var old = $.fn.inputmask
795 $.fn.inputmask = function (options) {
796 return this.each(function () {
798 var data = $this.data('bs.inputmask')
800 if (!data) $this.data('bs.inputmask', (data = new Inputmask(this, options)))
804 $.fn.inputmask.Constructor = Inputmask
807 // INPUTMASK NO CONFLICT
808 // ====================
810 $.fn.inputmask.noConflict = function () {
816 // INPUTMASK DATA-API
817 // ==================
819 $(document).on('focus.bs.inputmask.data-api', '[data-mask]', function (e) {
821 if ($this.data('bs.inputmask')) return
822 $this.inputmask($this.data())
827 /* ===========================================================
828 * Bootstrap: fileinput.js v3.1.3
829 * http://jasny.github.com/bootstrap/javascript/#fileinput
830 * ===========================================================
831 * Copyright 2012-2014 Arnold Daniels
833 * Licensed under the Apache License, Version 2.0 (the "License")
834 * you may not use this file except in compliance with the License.
835 * You may obtain a copy of the License at
837 * http://www.apache.org/licenses/LICENSE-2.0
839 * Unless required by applicable law or agreed to in writing, software
840 * distributed under the License is distributed on an "AS IS" BASIS,
841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
842 * See the License for the specific language governing permissions and
843 * limitations under the License.
844 * ========================================================== */
846 +function ($) { "use strict";
848 var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
850 // FILEUPLOAD PUBLIC CLASS DEFINITION
851 // =================================
853 var Fileinput = function (element, options) {
854 this.$element = $(element)
856 this.$input = this.$element.find(':file')
857 if (this.$input.length === 0) return
859 this.name = this.$input.attr('name') || options.name
861 this.$hidden = this.$element.find('input[type=hidden][name="' + this.name + '"]')
862 if (this.$hidden.length === 0) {
863 this.$hidden = $('<input type="hidden">').insertBefore(this.$input)
866 this.$preview = this.$element.find('.fileinput-preview')
867 var height = this.$preview.css('height')
868 if (this.$preview.css('display') !== 'inline' && height !== '0px' && height !== 'none') {
869 this.$preview.css('line-height', height)
873 exists: this.$element.hasClass('fileinput-exists'),
874 preview: this.$preview.html(),
875 hiddenVal: this.$hidden.val()
881 Fileinput.prototype.listen = function() {
882 this.$input.on('change.bs.fileinput', $.proxy(this.change, this))
883 $(this.$input[0].form).on('reset.bs.fileinput', $.proxy(this.reset, this))
885 this.$element.find('[data-trigger="fileinput"]').on('click.bs.fileinput', $.proxy(this.trigger, this))
886 this.$element.find('[data-dismiss="fileinput"]').on('click.bs.fileinput', $.proxy(this.clear, this))
889 Fileinput.prototype.change = function(e) {
890 var files = e.target.files === undefined ? (e.target && e.target.value ? [{ name: e.target.value.replace(/^.+\\/, '')}] : []) : e.target.files
894 if (files.length === 0) {
900 this.$hidden.attr('name', '')
901 this.$input.attr('name', this.name)
905 if (this.$preview.length > 0 && (typeof file.type !== "undefined" ? file.type.match(/^image\/(gif|png|jpeg)$/) : file.name.match(/\.(gif|png|jpe?g)$/i)) && typeof FileReader !== "undefined") {
906 var reader = new FileReader()
907 var preview = this.$preview
908 var element = this.$element
910 reader.onload = function(re) {
911 var $img = $('<img>')
912 $img[0].src = re.target.result
913 files[0].result = re.target.result
915 element.find('.fileinput-filename').text(file.name)
917 // if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account
918 if (preview.css('max-height') != 'none') $img.css('max-height', parseInt(preview.css('max-height'), 10) - parseInt(preview.css('padding-top'), 10) - parseInt(preview.css('padding-bottom'), 10) - parseInt(preview.css('border-top'), 10) - parseInt(preview.css('border-bottom'), 10))
921 element.addClass('fileinput-exists').removeClass('fileinput-new')
923 element.trigger('change.bs.fileinput', files)
926 reader.readAsDataURL(file)
928 this.$element.find('.fileinput-filename').text(file.name)
929 this.$preview.text(file.name)
931 this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
933 this.$element.trigger('change.bs.fileinput')
937 Fileinput.prototype.clear = function(e) {
938 if (e) e.preventDefault()
941 this.$hidden.attr('name', this.name)
942 this.$input.attr('name', '')
944 //ie8+ doesn't support changing the value of input with type=file so clone instead
946 var inputClone = this.$input.clone(true);
947 this.$input.after(inputClone);
948 this.$input.remove();
949 this.$input = inputClone;
954 this.$preview.html('')
955 this.$element.find('.fileinput-filename').text('')
956 this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
958 if (e !== undefined) {
959 this.$input.trigger('change')
960 this.$element.trigger('clear.bs.fileinput')
964 Fileinput.prototype.reset = function() {
967 this.$hidden.val(this.original.hiddenVal)
968 this.$preview.html(this.original.preview)
969 this.$element.find('.fileinput-filename').text('')
971 if (this.original.exists) this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
972 else this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
974 this.$element.trigger('reset.bs.fileinput')
977 Fileinput.prototype.trigger = function(e) {
978 this.$input.trigger('click')
983 // FILEUPLOAD PLUGIN DEFINITION
984 // ===========================
986 var old = $.fn.fileinput
988 $.fn.fileinput = function (options) {
989 return this.each(function () {
991 data = $this.data('bs.fileinput')
992 if (!data) $this.data('bs.fileinput', (data = new Fileinput(this, options)))
993 if (typeof options == 'string') data[options]()
997 $.fn.fileinput.Constructor = Fileinput
1000 // FILEINPUT NO CONFLICT
1001 // ====================
1003 $.fn.fileinput.noConflict = function () {
1004 $.fn.fileinput = old
1009 // FILEUPLOAD DATA-API
1010 // ==================
1012 $(document).on('click.fileinput.data-api', '[data-provides="fileinput"]', function (e) {
1014 if ($this.data('bs.fileinput')) return
1015 $this.fileinput($this.data())
1017 var $target = $(e.target).closest('[data-dismiss="fileinput"],[data-trigger="fileinput"]');
1018 if ($target.length > 0) {
1020 $target.trigger('click.bs.fileinput')