jasny-bootstrap-rails 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/LICENSE +21 -0
- data/README.md +45 -0
- data/jasny-bootstrap-rails.gemspec +19 -0
- data/lib/jasny-bootstrap-rails.rb +6 -0
- data/lib/jasny-bootstrap-rails/engine.rb +6 -0
- data/lib/jasny-bootstrap-rails/version.rb +6 -0
- data/vendor/assets/javascripts/jasny-bootstrap.js +1024 -0
- data/vendor/assets/javascripts/jasny-bootstrap.min.js +6 -0
- data/vendor/assets/stylesheets/jasny-bootstrap.css +621 -0
- data/vendor/assets/stylesheets/jasny-bootstrap.css.map +1 -0
- data/vendor/assets/stylesheets/jasny-bootstrap.min.css +7 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21c98819ff9c7da0af28fffebb0c5451dc0869e9
|
4
|
+
data.tar.gz: a080f5762293881609574d5b10461b953be3da93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea69937ace5eda08a279d8165f3fca9231d4531842942ae7f97ffbb6b7197204c36fb339b0352199fa6af3b42158c2215401e28eacbebc935425a7971abee666
|
7
|
+
data.tar.gz: cba6ac87e40c6cfec86ab5a38af55b7cc87551aa4aa9b9d79ad24317255d657481710ef72e96901af2f6cf2e8a9164ad281f0d01ea201c9a7b9a7b75045b6d1d
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Benjamin Hüttinger
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
jasny-bootstrap-rails (3.1.3.0)
|
2
|
+
=================================
|
3
|
+
|
4
|
+
The original Jasny Bootstrap extension can be found here: http://jasny.github.io/bootstrap/.
|
5
|
+
This is only a gem containing a release version for easier use with Ruby on Rails.
|
6
|
+
|
7
|
+
|
8
|
+
### How to Use
|
9
|
+
|
10
|
+
#### Add and install this gem
|
11
|
+
|
12
|
+
**Add into your Gemfile**
|
13
|
+
|
14
|
+
`gem 'jasny-bootstrap-rails'`
|
15
|
+
|
16
|
+
You also need to require bootstrap.
|
17
|
+
As there are different packages (sass/less) there is no fixed requirement:
|
18
|
+
|
19
|
+
```
|
20
|
+
gem 'twitter-bootstrap-rails'
|
21
|
+
or
|
22
|
+
gem 'bootstrap-sass'
|
23
|
+
or
|
24
|
+
...
|
25
|
+
```
|
26
|
+
|
27
|
+
**In your Rails directory run**
|
28
|
+
|
29
|
+
`bundle install`
|
30
|
+
|
31
|
+
#### Add the needed parts to your asset pipeline, after your bootstrap requires
|
32
|
+
|
33
|
+
**Add into your application.js**
|
34
|
+
|
35
|
+
`//= require jasny-bootstrap.min`
|
36
|
+
|
37
|
+
|
38
|
+
**Add into your application.css**
|
39
|
+
|
40
|
+
`*= require jasny-bootstrap.min`
|
41
|
+
|
42
|
+
|
43
|
+
### Note
|
44
|
+
|
45
|
+
There are some alternatives to this Gem out in the wild but i havent found any close to up to date.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../lib/jasny-bootstrap-rails/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ['Benjamin Hüttinger']
|
5
|
+
gem.email = ['benjamin.huettinger@gmail.com']
|
6
|
+
gem.description = %q{Rails Gegm to extends Bootstrap with some additional features. Source http://jasny.github.io/bootstrap/}
|
7
|
+
gem.homepage = 'https://github.com/maxigs/jasny-bootstrap-rails'
|
8
|
+
gem.summary = gem.description
|
9
|
+
|
10
|
+
gem.name = 'jasny-bootstrap-rails'
|
11
|
+
gem.require_paths = ['lib']
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.version = JasnyBootstrapRails::Rails::VERSION
|
14
|
+
gem.platform = Gem::Platform::RUBY
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
gem.add_dependency 'railties', '>= 3.0'
|
18
|
+
gem.add_development_dependency 'bundler', '>= 1.0'
|
19
|
+
end
|
@@ -0,0 +1,1024 @@
|
|
1
|
+
/*!
|
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)
|
5
|
+
*/
|
6
|
+
|
7
|
+
if (typeof jQuery === 'undefined') { throw new Error('Jasny Bootstrap\'s JavaScript requires jQuery') }
|
8
|
+
|
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
|
+
* ======================================================================== */
|
16
|
+
|
17
|
+
|
18
|
+
+function ($) {
|
19
|
+
'use strict';
|
20
|
+
|
21
|
+
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
|
22
|
+
// ============================================================
|
23
|
+
|
24
|
+
function transitionEnd() {
|
25
|
+
var el = document.createElement('bootstrap')
|
26
|
+
|
27
|
+
var transEndEventNames = {
|
28
|
+
WebkitTransition : 'webkitTransitionEnd',
|
29
|
+
MozTransition : 'transitionend',
|
30
|
+
OTransition : 'oTransitionEnd otransitionend',
|
31
|
+
transition : 'transitionend'
|
32
|
+
}
|
33
|
+
|
34
|
+
for (var name in transEndEventNames) {
|
35
|
+
if (el.style[name] !== undefined) {
|
36
|
+
return { end: transEndEventNames[name] }
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return false // explicit for ie8 ( ._.)
|
41
|
+
}
|
42
|
+
|
43
|
+
if ($.support.transition !== undefined) return // Prevent conflict with Twitter Bootstrap
|
44
|
+
|
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)
|
51
|
+
return this
|
52
|
+
}
|
53
|
+
|
54
|
+
$(function () {
|
55
|
+
$.support.transition = transitionEnd()
|
56
|
+
})
|
57
|
+
|
58
|
+
}(window.jQuery);
|
59
|
+
|
60
|
+
/* ========================================================================
|
61
|
+
* Bootstrap: offcanvas.js v3.1.3
|
62
|
+
* http://jasny.github.io/bootstrap/javascript/#offcanvas
|
63
|
+
* ========================================================================
|
64
|
+
* Copyright 2013-2014 Arnold Daniels
|
65
|
+
*
|
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
|
69
|
+
*
|
70
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
71
|
+
*
|
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
|
+
* ======================================================================== */
|
78
|
+
|
79
|
+
+function ($) { "use strict";
|
80
|
+
|
81
|
+
// OFFCANVAS PUBLIC CLASS DEFINITION
|
82
|
+
// =================================
|
83
|
+
|
84
|
+
var OffCanvas = function (element, options) {
|
85
|
+
this.$element = $(element)
|
86
|
+
this.options = $.extend({}, OffCanvas.DEFAULTS, options)
|
87
|
+
this.state = null
|
88
|
+
this.placement = null
|
89
|
+
|
90
|
+
if (this.options.recalc) {
|
91
|
+
this.calcClone()
|
92
|
+
$(window).on('resize', $.proxy(this.recalc, this))
|
93
|
+
}
|
94
|
+
|
95
|
+
if (this.options.autohide)
|
96
|
+
$(document).on('click', $.proxy(this.autohide, this))
|
97
|
+
|
98
|
+
if (this.options.toggle) this.toggle()
|
99
|
+
|
100
|
+
if (this.options.disablescrolling) {
|
101
|
+
this.options.disableScrolling = this.options.disablescrolling
|
102
|
+
delete this.options.disablescrolling
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
OffCanvas.DEFAULTS = {
|
107
|
+
toggle: true,
|
108
|
+
placement: 'auto',
|
109
|
+
autohide: true,
|
110
|
+
recalc: true,
|
111
|
+
disableScrolling: true
|
112
|
+
}
|
113
|
+
|
114
|
+
OffCanvas.prototype.offset = function () {
|
115
|
+
switch (this.placement) {
|
116
|
+
case 'left':
|
117
|
+
case 'right': return this.$element.outerWidth()
|
118
|
+
case 'top':
|
119
|
+
case 'bottom': return this.$element.outerHeight()
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
OffCanvas.prototype.calcPlacement = function () {
|
124
|
+
if (this.options.placement !== 'auto') {
|
125
|
+
this.placement = this.options.placement
|
126
|
+
return
|
127
|
+
}
|
128
|
+
|
129
|
+
if (!this.$element.hasClass('in')) {
|
130
|
+
this.$element.css('visiblity', 'hidden !important').addClass('in')
|
131
|
+
}
|
132
|
+
|
133
|
+
var horizontal = $(window).width() / this.$element.width()
|
134
|
+
var vertical = $(window).height() / this.$element.height()
|
135
|
+
|
136
|
+
var element = this.$element
|
137
|
+
function ab(a, b) {
|
138
|
+
if (element.css(b) === 'auto') return a
|
139
|
+
if (element.css(a) === 'auto') return b
|
140
|
+
|
141
|
+
var size_a = parseInt(element.css(a), 10)
|
142
|
+
var size_b = parseInt(element.css(b), 10)
|
143
|
+
|
144
|
+
return size_a > size_b ? b : a
|
145
|
+
}
|
146
|
+
|
147
|
+
this.placement = horizontal >= vertical ? ab('left', 'right') : ab('top', 'bottom')
|
148
|
+
|
149
|
+
if (this.$element.css('visibility') === 'hidden !important') {
|
150
|
+
this.$element.removeClass('in').css('visiblity', '')
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
OffCanvas.prototype.opposite = function (placement) {
|
155
|
+
switch (placement) {
|
156
|
+
case 'top': return 'bottom'
|
157
|
+
case 'left': return 'right'
|
158
|
+
case 'bottom': return 'top'
|
159
|
+
case 'right': return 'left'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
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
|
166
|
+
|
167
|
+
var fixed_elements = canvas.find('*').filter(function() {
|
168
|
+
return $(this).css('position') === 'fixed'
|
169
|
+
}).not(this.options.exclude)
|
170
|
+
|
171
|
+
return canvas.add(fixed_elements)
|
172
|
+
}
|
173
|
+
|
174
|
+
OffCanvas.prototype.slide = function (elements, offset, callback) {
|
175
|
+
// Use jQuery animation if CSS transitions aren't supported
|
176
|
+
if (!$.support.transition) {
|
177
|
+
var anim = {}
|
178
|
+
anim[this.placement] = "+=" + offset
|
179
|
+
return elements.animate(anim, 350, callback)
|
180
|
+
}
|
181
|
+
|
182
|
+
var placement = this.placement
|
183
|
+
var opposite = this.opposite(placement)
|
184
|
+
|
185
|
+
elements.each(function() {
|
186
|
+
if ($(this).css(placement) !== 'auto')
|
187
|
+
$(this).css(placement, (parseInt($(this).css(placement), 10) || 0) + offset)
|
188
|
+
|
189
|
+
if ($(this).css(opposite) !== 'auto')
|
190
|
+
$(this).css(opposite, (parseInt($(this).css(opposite), 10) || 0) - offset)
|
191
|
+
})
|
192
|
+
|
193
|
+
this.$element
|
194
|
+
.one($.support.transition.end, callback)
|
195
|
+
.emulateTransitionEnd(350)
|
196
|
+
}
|
197
|
+
|
198
|
+
OffCanvas.prototype.disableScrolling = function() {
|
199
|
+
var bodyWidth = $('body').width()
|
200
|
+
var prop = 'padding-' + this.opposite(this.placement)
|
201
|
+
|
202
|
+
if ($('body').data('offcanvas-style') === undefined) {
|
203
|
+
$('body').data('offcanvas-style', $('body').attr('style') || '')
|
204
|
+
}
|
205
|
+
|
206
|
+
$('body').css('overflow', 'hidden')
|
207
|
+
|
208
|
+
if ($('body').width() > bodyWidth) {
|
209
|
+
var padding = parseInt($('body').css(prop), 10) + $('body').width() - bodyWidth
|
210
|
+
|
211
|
+
setTimeout(function() {
|
212
|
+
$('body').css(prop, padding)
|
213
|
+
}, 1)
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
OffCanvas.prototype.show = function () {
|
218
|
+
if (this.state) return
|
219
|
+
|
220
|
+
var startEvent = $.Event('show.bs.offcanvas')
|
221
|
+
this.$element.trigger(startEvent)
|
222
|
+
if (startEvent.isDefaultPrevented()) return
|
223
|
+
|
224
|
+
this.state = 'slide-in'
|
225
|
+
this.calcPlacement();
|
226
|
+
|
227
|
+
var elements = this.getCanvasElements()
|
228
|
+
var placement = this.placement
|
229
|
+
var opposite = this.opposite(placement)
|
230
|
+
var offset = this.offset()
|
231
|
+
|
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
|
236
|
+
}
|
237
|
+
|
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)
|
244
|
+
}
|
245
|
+
})
|
246
|
+
|
247
|
+
if (this.options.disableScrolling) this.disableScrolling()
|
248
|
+
|
249
|
+
var complete = function () {
|
250
|
+
if (this.state != 'slide-in') return
|
251
|
+
|
252
|
+
this.state = 'slid'
|
253
|
+
|
254
|
+
elements.removeClass('canvas-sliding').addClass('canvas-slid')
|
255
|
+
this.$element.trigger('shown.bs.offcanvas')
|
256
|
+
}
|
257
|
+
|
258
|
+
setTimeout($.proxy(function() {
|
259
|
+
this.$element.addClass('in')
|
260
|
+
this.slide(elements, offset, $.proxy(complete, this))
|
261
|
+
}, this), 1)
|
262
|
+
}
|
263
|
+
|
264
|
+
OffCanvas.prototype.hide = function (fast) {
|
265
|
+
if (this.state !== 'slid') return
|
266
|
+
|
267
|
+
var startEvent = $.Event('hide.bs.offcanvas')
|
268
|
+
this.$element.trigger(startEvent)
|
269
|
+
if (startEvent.isDefaultPrevented()) return
|
270
|
+
|
271
|
+
this.state = 'slide-out'
|
272
|
+
|
273
|
+
var elements = $('.canvas-slid')
|
274
|
+
var placement = this.placement
|
275
|
+
var offset = -1 * this.offset()
|
276
|
+
|
277
|
+
var complete = function () {
|
278
|
+
if (this.state != 'slide-out') return
|
279
|
+
|
280
|
+
this.state = null
|
281
|
+
this.placement = null
|
282
|
+
|
283
|
+
this.$element.removeClass('in')
|
284
|
+
|
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')
|
288
|
+
})
|
289
|
+
|
290
|
+
this.$element.trigger('hidden.bs.offcanvas')
|
291
|
+
}
|
292
|
+
|
293
|
+
elements.removeClass('canvas-slid').addClass('canvas-sliding')
|
294
|
+
|
295
|
+
setTimeout($.proxy(function() {
|
296
|
+
this.slide(elements, offset, $.proxy(complete, this))
|
297
|
+
}, this), 1)
|
298
|
+
}
|
299
|
+
|
300
|
+
OffCanvas.prototype.toggle = function () {
|
301
|
+
if (this.state === 'slide-in' || this.state === 'slide-out') return
|
302
|
+
this[this.state === 'slid' ? 'hide' : 'show']()
|
303
|
+
}
|
304
|
+
|
305
|
+
OffCanvas.prototype.calcClone = function() {
|
306
|
+
this.$calcClone = this.$element.clone()
|
307
|
+
.html('')
|
308
|
+
.addClass('offcanvas-clone').removeClass('in')
|
309
|
+
.appendTo($('body'))
|
310
|
+
}
|
311
|
+
|
312
|
+
OffCanvas.prototype.recalc = function () {
|
313
|
+
if (this.$calcClone.css('display') === 'none' || (this.state !== 'slid' && this.state !== 'slide-in')) return
|
314
|
+
|
315
|
+
this.state = null
|
316
|
+
this.placement = null
|
317
|
+
var elements = this.getCanvasElements()
|
318
|
+
|
319
|
+
this.$element.removeClass('in')
|
320
|
+
|
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')
|
324
|
+
})
|
325
|
+
}
|
326
|
+
|
327
|
+
OffCanvas.prototype.autohide = function (e) {
|
328
|
+
if ($(e.target).closest(this.$element).length === 0) this.hide()
|
329
|
+
}
|
330
|
+
|
331
|
+
// OFFCANVAS PLUGIN DEFINITION
|
332
|
+
// ==========================
|
333
|
+
|
334
|
+
var old = $.fn.offcanvas
|
335
|
+
|
336
|
+
$.fn.offcanvas = function (option) {
|
337
|
+
return this.each(function () {
|
338
|
+
var $this = $(this)
|
339
|
+
var data = $this.data('bs.offcanvas')
|
340
|
+
var options = $.extend({}, OffCanvas.DEFAULTS, $this.data(), typeof option === 'object' && option)
|
341
|
+
|
342
|
+
if (!data) $this.data('bs.offcanvas', (data = new OffCanvas(this, options)))
|
343
|
+
if (typeof option === 'string') data[option]()
|
344
|
+
})
|
345
|
+
}
|
346
|
+
|
347
|
+
$.fn.offcanvas.Constructor = OffCanvas
|
348
|
+
|
349
|
+
|
350
|
+
// OFFCANVAS NO CONFLICT
|
351
|
+
// ====================
|
352
|
+
|
353
|
+
$.fn.offcanvas.noConflict = function () {
|
354
|
+
$.fn.offcanvas = old
|
355
|
+
return this
|
356
|
+
}
|
357
|
+
|
358
|
+
|
359
|
+
// OFFCANVAS DATA-API
|
360
|
+
// =================
|
361
|
+
|
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()
|
370
|
+
|
371
|
+
e.stopPropagation()
|
372
|
+
|
373
|
+
if (data) data.toggle()
|
374
|
+
else $canvas.offcanvas(option)
|
375
|
+
})
|
376
|
+
|
377
|
+
}(window.jQuery);
|
378
|
+
|
379
|
+
/* ============================================================
|
380
|
+
* Bootstrap: rowlink.js v3.1.3
|
381
|
+
* http://jasny.github.io/bootstrap/javascript/#rowlink
|
382
|
+
* ============================================================
|
383
|
+
* Copyright 2012-2014 Arnold Daniels
|
384
|
+
*
|
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
|
388
|
+
*
|
389
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
390
|
+
*
|
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
|
+
* ============================================================ */
|
397
|
+
|
398
|
+
+function ($) { "use strict";
|
399
|
+
|
400
|
+
var Rowlink = function (element, options) {
|
401
|
+
this.$element = $(element)
|
402
|
+
this.options = $.extend({}, Rowlink.DEFAULTS, options)
|
403
|
+
|
404
|
+
this.$element.on('click.bs.rowlink', 'td:not(.rowlink-skip)', $.proxy(this.click, this))
|
405
|
+
}
|
406
|
+
|
407
|
+
Rowlink.DEFAULTS = {
|
408
|
+
target: "a"
|
409
|
+
}
|
410
|
+
|
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
|
414
|
+
|
415
|
+
e.preventDefault();
|
416
|
+
|
417
|
+
if (target.click) {
|
418
|
+
target.click()
|
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);
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
|
427
|
+
// ROWLINK PLUGIN DEFINITION
|
428
|
+
// ===========================
|
429
|
+
|
430
|
+
var old = $.fn.rowlink
|
431
|
+
|
432
|
+
$.fn.rowlink = function (options) {
|
433
|
+
return this.each(function () {
|
434
|
+
var $this = $(this)
|
435
|
+
var data = $this.data('bs.rowlink')
|
436
|
+
if (!data) $this.data('bs.rowlink', (data = new Rowlink(this, options)))
|
437
|
+
})
|
438
|
+
}
|
439
|
+
|
440
|
+
$.fn.rowlink.Constructor = Rowlink
|
441
|
+
|
442
|
+
|
443
|
+
// ROWLINK NO CONFLICT
|
444
|
+
// ====================
|
445
|
+
|
446
|
+
$.fn.rowlink.noConflict = function () {
|
447
|
+
$.fn.rowlink = old
|
448
|
+
return this
|
449
|
+
}
|
450
|
+
|
451
|
+
|
452
|
+
// ROWLINK DATA-API
|
453
|
+
// ==================
|
454
|
+
|
455
|
+
$(document).on('click.bs.rowlink.data-api', '[data-link="row"]', function (e) {
|
456
|
+
if ($(e.target).closest('.rowlink-skip').length !== 0) return
|
457
|
+
|
458
|
+
var $this = $(this)
|
459
|
+
if ($this.data('bs.rowlink')) return
|
460
|
+
$this.rowlink($this.data())
|
461
|
+
$(e.target).trigger('click.bs.rowlink')
|
462
|
+
})
|
463
|
+
|
464
|
+
}(window.jQuery);
|
465
|
+
|
466
|
+
/* ===========================================================
|
467
|
+
* Bootstrap: inputmask.js v3.1.0
|
468
|
+
* http://jasny.github.io/bootstrap/javascript/#inputmask
|
469
|
+
*
|
470
|
+
* Based on Masked Input plugin by Josh Bush (digitalbush.com)
|
471
|
+
* ===========================================================
|
472
|
+
* Copyright 2012-2014 Arnold Daniels
|
473
|
+
*
|
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
|
477
|
+
*
|
478
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
479
|
+
*
|
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
|
+
* ========================================================== */
|
486
|
+
|
487
|
+
+function ($) { "use strict";
|
488
|
+
|
489
|
+
var isIphone = (window.orientation !== undefined)
|
490
|
+
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
|
491
|
+
var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
|
492
|
+
|
493
|
+
// INPUTMASK PUBLIC CLASS DEFINITION
|
494
|
+
// =================================
|
495
|
+
|
496
|
+
var Inputmask = function (element, options) {
|
497
|
+
if (isAndroid) return // No support because caret positioning doesn't work on Android
|
498
|
+
|
499
|
+
this.$element = $(element)
|
500
|
+
this.options = $.extend({}, Inputmask.DEFAULTS, options)
|
501
|
+
this.mask = String(this.options.mask)
|
502
|
+
|
503
|
+
this.init()
|
504
|
+
this.listen()
|
505
|
+
|
506
|
+
this.checkVal() //Perform initial check for existing values
|
507
|
+
}
|
508
|
+
|
509
|
+
Inputmask.DEFAULTS = {
|
510
|
+
mask: "",
|
511
|
+
placeholder: "_",
|
512
|
+
definitions: {
|
513
|
+
'9': "[0-9]",
|
514
|
+
'a': "[A-Za-z]",
|
515
|
+
'w': "[A-Za-z0-9]",
|
516
|
+
'*': "."
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
Inputmask.prototype.init = function() {
|
521
|
+
var defs = this.options.definitions
|
522
|
+
var len = this.mask.length
|
523
|
+
|
524
|
+
this.tests = []
|
525
|
+
this.partialPosition = this.mask.length
|
526
|
+
this.firstNonMaskPos = null
|
527
|
+
|
528
|
+
$.each(this.mask.split(""), $.proxy(function(i, c) {
|
529
|
+
if (c == '?') {
|
530
|
+
len--
|
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
|
536
|
+
} else {
|
537
|
+
this.tests.push(null)
|
538
|
+
}
|
539
|
+
}, this))
|
540
|
+
|
541
|
+
this.buffer = $.map(this.mask.split(""), $.proxy(function(c, i) {
|
542
|
+
if (c != '?') return defs[c] ? this.options.placeholder : c
|
543
|
+
}, this))
|
544
|
+
|
545
|
+
this.focusText = this.$element.val()
|
546
|
+
|
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
|
550
|
+
}).join('')
|
551
|
+
}, this))
|
552
|
+
}
|
553
|
+
|
554
|
+
Inputmask.prototype.listen = function() {
|
555
|
+
if (this.$element.attr("readonly")) return
|
556
|
+
|
557
|
+
var pasteEventName = (isIE ? 'paste' : 'input') + ".mask"
|
558
|
+
|
559
|
+
this.$element
|
560
|
+
.on("unmask.bs.inputmask", $.proxy(this.unmask, this))
|
561
|
+
|
562
|
+
.on("focus.bs.inputmask", $.proxy(this.focusEvent, this))
|
563
|
+
.on("blur.bs.inputmask", $.proxy(this.blurEvent, this))
|
564
|
+
|
565
|
+
.on("keydown.bs.inputmask", $.proxy(this.keydownEvent, this))
|
566
|
+
.on("keypress.bs.inputmask", $.proxy(this.keypressEvent, this))
|
567
|
+
|
568
|
+
.on(pasteEventName, $.proxy(this.pasteEvent, this))
|
569
|
+
}
|
570
|
+
|
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()
|
581
|
+
range.collapse(true)
|
582
|
+
range.moveEnd('character', end)
|
583
|
+
range.moveStart('character', begin)
|
584
|
+
range.select()
|
585
|
+
}
|
586
|
+
})
|
587
|
+
} else {
|
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
|
595
|
+
}
|
596
|
+
return {
|
597
|
+
begin: begin,
|
598
|
+
end: end
|
599
|
+
}
|
600
|
+
}
|
601
|
+
}
|
602
|
+
|
603
|
+
Inputmask.prototype.seekNext = function(pos) {
|
604
|
+
var len = this.mask.length
|
605
|
+
while (++pos <= len && !this.tests[pos]);
|
606
|
+
|
607
|
+
return pos
|
608
|
+
}
|
609
|
+
|
610
|
+
Inputmask.prototype.seekPrev = function(pos) {
|
611
|
+
while (--pos >= 0 && !this.tests[pos]);
|
612
|
+
|
613
|
+
return pos
|
614
|
+
}
|
615
|
+
|
616
|
+
Inputmask.prototype.shiftL = function(begin,end) {
|
617
|
+
var len = this.mask.length
|
618
|
+
|
619
|
+
if (begin < 0) return
|
620
|
+
|
621
|
+
for (var i = begin, j = this.seekNext(end); i < len; i++) {
|
622
|
+
if (this.tests[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
|
626
|
+
} else
|
627
|
+
break
|
628
|
+
j = this.seekNext(j)
|
629
|
+
}
|
630
|
+
}
|
631
|
+
this.writeBuffer()
|
632
|
+
this.caret(Math.max(this.firstNonMaskPos, begin))
|
633
|
+
}
|
634
|
+
|
635
|
+
Inputmask.prototype.shiftR = function(pos) {
|
636
|
+
var len = this.mask.length
|
637
|
+
|
638
|
+
for (var i = pos, c = this.options.placeholder; i < len; i++) {
|
639
|
+
if (this.tests[i]) {
|
640
|
+
var j = this.seekNext(i)
|
641
|
+
var t = this.buffer[i]
|
642
|
+
this.buffer[i] = c
|
643
|
+
if (j < len && this.tests[j].test(t))
|
644
|
+
c = t
|
645
|
+
else
|
646
|
+
break
|
647
|
+
}
|
648
|
+
}
|
649
|
+
},
|
650
|
+
|
651
|
+
Inputmask.prototype.unmask = function() {
|
652
|
+
this.$element
|
653
|
+
.unbind(".mask")
|
654
|
+
.removeData("inputmask")
|
655
|
+
}
|
656
|
+
|
657
|
+
Inputmask.prototype.focusEvent = function() {
|
658
|
+
this.focusText = this.$element.val()
|
659
|
+
var len = this.mask.length
|
660
|
+
var pos = this.checkVal()
|
661
|
+
this.writeBuffer()
|
662
|
+
|
663
|
+
var that = this
|
664
|
+
var moveCaret = function() {
|
665
|
+
if (pos == len)
|
666
|
+
that.caret(0, pos)
|
667
|
+
else
|
668
|
+
that.caret(pos)
|
669
|
+
}
|
670
|
+
|
671
|
+
moveCaret()
|
672
|
+
setTimeout(moveCaret, 50)
|
673
|
+
}
|
674
|
+
|
675
|
+
Inputmask.prototype.blurEvent = function() {
|
676
|
+
this.checkVal()
|
677
|
+
if (this.$element.val() !== this.focusText)
|
678
|
+
this.$element.trigger('change')
|
679
|
+
}
|
680
|
+
|
681
|
+
Inputmask.prototype.keydownEvent = function(e) {
|
682
|
+
var k = e.which
|
683
|
+
|
684
|
+
//backspace, delete, and escape get special treatment
|
685
|
+
if (k == 8 || k == 46 || (isIphone && k == 127)) {
|
686
|
+
var pos = this.caret(),
|
687
|
+
begin = pos.begin,
|
688
|
+
end = pos.end
|
689
|
+
|
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
|
693
|
+
}
|
694
|
+
this.clearBuffer(begin, end)
|
695
|
+
this.shiftL(begin, end - 1)
|
696
|
+
|
697
|
+
return false
|
698
|
+
} else if (k == 27) {//escape
|
699
|
+
this.$element.val(this.focusText)
|
700
|
+
this.caret(0, this.checkVal())
|
701
|
+
return false
|
702
|
+
}
|
703
|
+
}
|
704
|
+
|
705
|
+
Inputmask.prototype.keypressEvent = function(e) {
|
706
|
+
var len = this.mask.length
|
707
|
+
|
708
|
+
var k = e.which,
|
709
|
+
pos = this.caret()
|
710
|
+
|
711
|
+
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
|
712
|
+
return true
|
713
|
+
} else if (k) {
|
714
|
+
if (pos.end - pos.begin !== 0) {
|
715
|
+
this.clearBuffer(pos.begin, pos.end)
|
716
|
+
this.shiftL(pos.begin, pos.end - 1)
|
717
|
+
}
|
718
|
+
|
719
|
+
var p = this.seekNext(pos.begin - 1)
|
720
|
+
if (p < len) {
|
721
|
+
var c = String.fromCharCode(k)
|
722
|
+
if (this.tests[p].test(c)) {
|
723
|
+
this.shiftR(p)
|
724
|
+
this.buffer[p] = c
|
725
|
+
this.writeBuffer()
|
726
|
+
var next = this.seekNext(p)
|
727
|
+
this.caret(next)
|
728
|
+
}
|
729
|
+
}
|
730
|
+
return false
|
731
|
+
}
|
732
|
+
}
|
733
|
+
|
734
|
+
Inputmask.prototype.pasteEvent = function() {
|
735
|
+
var that = this
|
736
|
+
|
737
|
+
setTimeout(function() {
|
738
|
+
that.caret(that.checkVal(true))
|
739
|
+
}, 0)
|
740
|
+
}
|
741
|
+
|
742
|
+
Inputmask.prototype.clearBuffer = function(start, end) {
|
743
|
+
var len = this.mask.length
|
744
|
+
|
745
|
+
for (var i = start; i < end && i < len; i++) {
|
746
|
+
if (this.tests[i])
|
747
|
+
this.buffer[i] = this.options.placeholder
|
748
|
+
}
|
749
|
+
}
|
750
|
+
|
751
|
+
Inputmask.prototype.writeBuffer = function() {
|
752
|
+
return this.$element.val(this.buffer.join('')).val()
|
753
|
+
}
|
754
|
+
|
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()
|
759
|
+
var lastMatch = -1
|
760
|
+
|
761
|
+
for (var i = 0, pos = 0; i < len; i++) {
|
762
|
+
if (this.tests[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)) {
|
767
|
+
this.buffer[i] = c
|
768
|
+
lastMatch = i
|
769
|
+
break
|
770
|
+
}
|
771
|
+
}
|
772
|
+
if (pos > test.length)
|
773
|
+
break
|
774
|
+
} else if (this.buffer[i] == test.charAt(pos) && i != this.partialPosition) {
|
775
|
+
pos++
|
776
|
+
lastMatch = i
|
777
|
+
}
|
778
|
+
}
|
779
|
+
if (!allow && lastMatch + 1 < this.partialPosition) {
|
780
|
+
this.$element.val("")
|
781
|
+
this.clearBuffer(0, len)
|
782
|
+
} else if (allow || lastMatch + 1 >= this.partialPosition) {
|
783
|
+
this.writeBuffer()
|
784
|
+
if (!allow) this.$element.val(this.$element.val().substring(0, lastMatch + 1))
|
785
|
+
}
|
786
|
+
return (this.partialPosition ? i : this.firstNonMaskPos)
|
787
|
+
}
|
788
|
+
|
789
|
+
|
790
|
+
// INPUTMASK PLUGIN DEFINITION
|
791
|
+
// ===========================
|
792
|
+
|
793
|
+
var old = $.fn.inputmask
|
794
|
+
|
795
|
+
$.fn.inputmask = function (options) {
|
796
|
+
return this.each(function () {
|
797
|
+
var $this = $(this)
|
798
|
+
var data = $this.data('bs.inputmask')
|
799
|
+
|
800
|
+
if (!data) $this.data('bs.inputmask', (data = new Inputmask(this, options)))
|
801
|
+
})
|
802
|
+
}
|
803
|
+
|
804
|
+
$.fn.inputmask.Constructor = Inputmask
|
805
|
+
|
806
|
+
|
807
|
+
// INPUTMASK NO CONFLICT
|
808
|
+
// ====================
|
809
|
+
|
810
|
+
$.fn.inputmask.noConflict = function () {
|
811
|
+
$.fn.inputmask = old
|
812
|
+
return this
|
813
|
+
}
|
814
|
+
|
815
|
+
|
816
|
+
// INPUTMASK DATA-API
|
817
|
+
// ==================
|
818
|
+
|
819
|
+
$(document).on('focus.bs.inputmask.data-api', '[data-mask]', function (e) {
|
820
|
+
var $this = $(this)
|
821
|
+
if ($this.data('bs.inputmask')) return
|
822
|
+
$this.inputmask($this.data())
|
823
|
+
})
|
824
|
+
|
825
|
+
}(window.jQuery);
|
826
|
+
|
827
|
+
/* ===========================================================
|
828
|
+
* Bootstrap: fileinput.js v3.1.3
|
829
|
+
* http://jasny.github.com/bootstrap/javascript/#fileinput
|
830
|
+
* ===========================================================
|
831
|
+
* Copyright 2012-2014 Arnold Daniels
|
832
|
+
*
|
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
|
836
|
+
*
|
837
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
838
|
+
*
|
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
|
+
* ========================================================== */
|
845
|
+
|
846
|
+
+function ($) { "use strict";
|
847
|
+
|
848
|
+
var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
|
849
|
+
|
850
|
+
// FILEUPLOAD PUBLIC CLASS DEFINITION
|
851
|
+
// =================================
|
852
|
+
|
853
|
+
var Fileinput = function (element, options) {
|
854
|
+
this.$element = $(element)
|
855
|
+
|
856
|
+
this.$input = this.$element.find(':file')
|
857
|
+
if (this.$input.length === 0) return
|
858
|
+
|
859
|
+
this.name = this.$input.attr('name') || options.name
|
860
|
+
|
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)
|
864
|
+
}
|
865
|
+
|
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)
|
870
|
+
}
|
871
|
+
|
872
|
+
this.original = {
|
873
|
+
exists: this.$element.hasClass('fileinput-exists'),
|
874
|
+
preview: this.$preview.html(),
|
875
|
+
hiddenVal: this.$hidden.val()
|
876
|
+
}
|
877
|
+
|
878
|
+
this.listen()
|
879
|
+
}
|
880
|
+
|
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))
|
884
|
+
|
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))
|
887
|
+
},
|
888
|
+
|
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
|
891
|
+
|
892
|
+
e.stopPropagation()
|
893
|
+
|
894
|
+
if (files.length === 0) {
|
895
|
+
this.clear()
|
896
|
+
return
|
897
|
+
}
|
898
|
+
|
899
|
+
this.$hidden.val('')
|
900
|
+
this.$hidden.attr('name', '')
|
901
|
+
this.$input.attr('name', this.name)
|
902
|
+
|
903
|
+
var file = files[0]
|
904
|
+
|
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
|
909
|
+
|
910
|
+
reader.onload = function(re) {
|
911
|
+
var $img = $('<img>')
|
912
|
+
$img[0].src = re.target.result
|
913
|
+
files[0].result = re.target.result
|
914
|
+
|
915
|
+
element.find('.fileinput-filename').text(file.name)
|
916
|
+
|
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))
|
919
|
+
|
920
|
+
preview.html($img)
|
921
|
+
element.addClass('fileinput-exists').removeClass('fileinput-new')
|
922
|
+
|
923
|
+
element.trigger('change.bs.fileinput', files)
|
924
|
+
}
|
925
|
+
|
926
|
+
reader.readAsDataURL(file)
|
927
|
+
} else {
|
928
|
+
this.$element.find('.fileinput-filename').text(file.name)
|
929
|
+
this.$preview.text(file.name)
|
930
|
+
|
931
|
+
this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
|
932
|
+
|
933
|
+
this.$element.trigger('change.bs.fileinput')
|
934
|
+
}
|
935
|
+
},
|
936
|
+
|
937
|
+
Fileinput.prototype.clear = function(e) {
|
938
|
+
if (e) e.preventDefault()
|
939
|
+
|
940
|
+
this.$hidden.val('')
|
941
|
+
this.$hidden.attr('name', this.name)
|
942
|
+
this.$input.attr('name', '')
|
943
|
+
|
944
|
+
//ie8+ doesn't support changing the value of input with type=file so clone instead
|
945
|
+
if (isIE) {
|
946
|
+
var inputClone = this.$input.clone(true);
|
947
|
+
this.$input.after(inputClone);
|
948
|
+
this.$input.remove();
|
949
|
+
this.$input = inputClone;
|
950
|
+
} else {
|
951
|
+
this.$input.val('')
|
952
|
+
}
|
953
|
+
|
954
|
+
this.$preview.html('')
|
955
|
+
this.$element.find('.fileinput-filename').text('')
|
956
|
+
this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
|
957
|
+
|
958
|
+
if (e !== undefined) {
|
959
|
+
this.$input.trigger('change')
|
960
|
+
this.$element.trigger('clear.bs.fileinput')
|
961
|
+
}
|
962
|
+
},
|
963
|
+
|
964
|
+
Fileinput.prototype.reset = function() {
|
965
|
+
this.clear()
|
966
|
+
|
967
|
+
this.$hidden.val(this.original.hiddenVal)
|
968
|
+
this.$preview.html(this.original.preview)
|
969
|
+
this.$element.find('.fileinput-filename').text('')
|
970
|
+
|
971
|
+
if (this.original.exists) this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
|
972
|
+
else this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
|
973
|
+
|
974
|
+
this.$element.trigger('reset.bs.fileinput')
|
975
|
+
},
|
976
|
+
|
977
|
+
Fileinput.prototype.trigger = function(e) {
|
978
|
+
this.$input.trigger('click')
|
979
|
+
e.preventDefault()
|
980
|
+
}
|
981
|
+
|
982
|
+
|
983
|
+
// FILEUPLOAD PLUGIN DEFINITION
|
984
|
+
// ===========================
|
985
|
+
|
986
|
+
var old = $.fn.fileinput
|
987
|
+
|
988
|
+
$.fn.fileinput = function (options) {
|
989
|
+
return this.each(function () {
|
990
|
+
var $this = $(this),
|
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]()
|
994
|
+
})
|
995
|
+
}
|
996
|
+
|
997
|
+
$.fn.fileinput.Constructor = Fileinput
|
998
|
+
|
999
|
+
|
1000
|
+
// FILEINPUT NO CONFLICT
|
1001
|
+
// ====================
|
1002
|
+
|
1003
|
+
$.fn.fileinput.noConflict = function () {
|
1004
|
+
$.fn.fileinput = old
|
1005
|
+
return this
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
|
1009
|
+
// FILEUPLOAD DATA-API
|
1010
|
+
// ==================
|
1011
|
+
|
1012
|
+
$(document).on('click.fileinput.data-api', '[data-provides="fileinput"]', function (e) {
|
1013
|
+
var $this = $(this)
|
1014
|
+
if ($this.data('bs.fileinput')) return
|
1015
|
+
$this.fileinput($this.data())
|
1016
|
+
|
1017
|
+
var $target = $(e.target).closest('[data-dismiss="fileinput"],[data-trigger="fileinput"]');
|
1018
|
+
if ($target.length > 0) {
|
1019
|
+
e.preventDefault()
|
1020
|
+
$target.trigger('click.bs.fileinput')
|
1021
|
+
}
|
1022
|
+
})
|
1023
|
+
|
1024
|
+
}(window.jQuery);
|