flashgrid-ext 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,339 @@
1
+ +function ($) { "use strict";
2
+
3
+ var isIphone = (window.orientation !== undefined)
4
+ var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
5
+ var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
6
+
7
+ // INPUTMASK PUBLIC CLASS DEFINITION
8
+ // =================================
9
+
10
+ var Inputmask = function (element, options) {
11
+ if (isAndroid) return // No support because caret positioning doesn't work on Android
12
+
13
+ this.$element = $(element)
14
+ this.options = $.extend({}, Inputmask.DEFAULS, options)
15
+ this.mask = String(this.options.mask)
16
+
17
+ this.init()
18
+ this.listen()
19
+
20
+ this.checkVal() //Perform initial check for existing values
21
+ }
22
+
23
+ Inputmask.DEFAULS = {
24
+ mask: "",
25
+ placeholder: "_",
26
+ definitions: {
27
+ '9': "[0-9]",
28
+ 'a': "[A-Za-z]",
29
+ '?': "[A-Za-z0-9]",
30
+ '*': "."
31
+ }
32
+ }
33
+
34
+ Inputmask.prototype.init = function() {
35
+ var defs = this.options.definitions
36
+ var len = this.mask.length
37
+
38
+ this.tests = []
39
+ this.partialPosition = this.mask.length
40
+ this.firstNonMaskPos = null
41
+
42
+ $.each(this.mask.split(""), $.proxy(function(i, c) {
43
+ if (c == '?') {
44
+ len--
45
+ this.partialPosition = i
46
+ } else if (defs[c]) {
47
+ this.tests.push(new RegExp(defs[c]))
48
+ if(this.firstNonMaskPos === null)
49
+ this.firstNonMaskPos = this.tests.length - 1
50
+ } else {
51
+ this.tests.push(null)
52
+ }
53
+ }, this))
54
+
55
+ this.buffer = $.map(this.mask.split(""), $.proxy(function(c, i) {
56
+ if (c != '?') return defs[c] ? this.options.placeholder : c
57
+ }, this))
58
+
59
+ this.focusText = this.$element.val()
60
+
61
+ this.$element.data("rawMaskFn", $.proxy(function() {
62
+ return $.map(this.buffer, function(c, i) {
63
+ return this.tests[i] && c != this.options.placeholder ? c : null
64
+ }).join('')
65
+ }, this))
66
+ }
67
+
68
+ Inputmask.prototype.listen = function() {
69
+ if (this.$element.attr("readonly")) return
70
+
71
+ var pasteEventName = (isIE ? 'paste' : 'input') + ".mask"
72
+
73
+ this.$element
74
+ .on("unmask.bs.inputmask", $.proxy(this.unmask, this))
75
+
76
+ .on("focus.bs.inputmask", $.proxy(this.focusEvent, this))
77
+ .on("blur.bs.inputmask", $.proxy(this.blurEvent, this))
78
+
79
+ .on("keydown.bs.inputmask", $.proxy(this.keydownEvent, this))
80
+ .on("keypress.bs.inputmask", $.proxy(this.keypressEvent, this))
81
+
82
+ .on(pasteEventName, $.proxy(this.pasteEvent, this))
83
+ }
84
+
85
+ //Helper Function for Caret positioning
86
+ Inputmask.prototype.caret = function(begin, end) {
87
+ if (this.$element.length === 0) return
88
+ if (typeof begin == 'number') {
89
+ end = (typeof end == 'number') ? end : begin
90
+ return this.$element.each(function() {
91
+ if (this.setSelectionRange) {
92
+ this.setSelectionRange(begin, end)
93
+ } else if (this.createTextRange) {
94
+ var range = this.createTextRange()
95
+ range.collapse(true)
96
+ range.moveEnd('character', end)
97
+ range.moveStart('character', begin)
98
+ range.select()
99
+ }
100
+ })
101
+ } else {
102
+ if (this.$element[0].setSelectionRange) {
103
+ begin = this.$element[0].selectionStart
104
+ end = this.$element[0].selectionEnd
105
+ } else if (document.selection && document.selection.createRange) {
106
+ var range = document.selection.createRange()
107
+ begin = 0 - range.duplicate().moveStart('character', -100000)
108
+ end = begin + range.text.length
109
+ }
110
+ return {
111
+ begin: begin,
112
+ end: end
113
+ }
114
+ }
115
+ }
116
+
117
+ Inputmask.prototype.seekNext = function(pos) {
118
+ var len = this.mask.length
119
+ while (++pos <= len && !this.tests[pos]);
120
+
121
+ return pos
122
+ }
123
+
124
+ Inputmask.prototype.seekPrev = function(pos) {
125
+ while (--pos >= 0 && !this.tests[pos]);
126
+
127
+ return pos
128
+ }
129
+
130
+ Inputmask.prototype.shiftL = function(begin,end) {
131
+ var len = this.mask.length
132
+
133
+ if(begin<0) return
134
+
135
+ for (var i = begin,j = this.seekNext(end); i < len; i++) {
136
+ if (this.tests[i]) {
137
+ if (j < len && this.tests[i].test(this.buffer[j])) {
138
+ this.buffer[i] = this.buffer[j]
139
+ this.buffer[j] = this.options.placeholder
140
+ } else
141
+ break
142
+ j = this.seekNext(j)
143
+ }
144
+ }
145
+ this.writeBuffer()
146
+ this.caret(Math.max(this.firstNonMaskPos, begin))
147
+ }
148
+
149
+ Inputmask.prototype.shiftR = function(pos) {
150
+ var len = this.mask.length
151
+
152
+ for (var i = pos, c = this.options.placeholder; i < len; i++) {
153
+ if (this.tests[i]) {
154
+ var j = this.seekNext(i)
155
+ var t = this.buffer[i]
156
+ this.buffer[i] = c
157
+ if (j < len && this.tests[j].test(t))
158
+ c = t
159
+ else
160
+ break
161
+ }
162
+ }
163
+ },
164
+
165
+ Inputmask.prototype.unmask = function() {
166
+ this.$element
167
+ .unbind(".mask")
168
+ .removeData("inputmask")
169
+ }
170
+
171
+ Inputmask.prototype.focusEvent = function() {
172
+ this.focusText = this.$element.val()
173
+ var len = this.mask.length
174
+ var pos = this.checkVal()
175
+ this.writeBuffer()
176
+
177
+ var that = this
178
+ var moveCaret = function() {
179
+ if (pos == len)
180
+ that.caret(0, pos)
181
+ else
182
+ that.caret(pos)
183
+ }
184
+
185
+ moveCaret()
186
+ setTimeout(moveCaret, 50)
187
+ }
188
+
189
+ Inputmask.prototype.blurEvent = function() {
190
+ this.checkVal()
191
+ if (this.$element.val() !== this.focusText)
192
+ this.$element.trigger('change')
193
+ }
194
+
195
+ Inputmask.prototype.keydownEvent = function(e) {
196
+ var k=e.which
197
+
198
+ //backspace, delete, and escape get special treatment
199
+ if (k == 8 || k == 46 || (isIphone && k == 127)) {
200
+ var pos = this.caret(),
201
+ begin = pos.begin,
202
+ end = pos.end
203
+
204
+ if (end-begin === 0) {
205
+ begin = k!=46 ? this.seekPrev(begin) : (end=this.seekNext(begin-1))
206
+ end = k==46 ? this.seekNext(end) : end
207
+ }
208
+ this.clearBuffer(begin, end)
209
+ this.shiftL(begin,end-1)
210
+
211
+ return false
212
+ } else if (k == 27) {//escape
213
+ this.$element.val(this.focusText)
214
+ this.caret(0, this.checkVal())
215
+ return false
216
+ }
217
+ }
218
+
219
+ Inputmask.prototype.keypressEvent = function(e) {
220
+ var len = this.mask.length
221
+
222
+ var k = e.which,
223
+ pos = this.caret()
224
+
225
+ if (e.ctrlKey || e.altKey || e.metaKey || k<32) {//Ignore
226
+ return true
227
+ } else if (k) {
228
+ if (pos.end - pos.begin !== 0) {
229
+ this.clearBuffer(pos.begin, pos.end)
230
+ this.shiftL(pos.begin, pos.end-1)
231
+ }
232
+
233
+ var p = this.seekNext(pos.begin - 1)
234
+ if (p < len) {
235
+ var c = String.fromCharCode(k)
236
+ if (this.tests[p].test(c)) {
237
+ this.shiftR(p)
238
+ this.buffer[p] = c
239
+ this.writeBuffer()
240
+ var next = this.seekNext(p)
241
+ this.caret(next)
242
+ }
243
+ }
244
+ return false
245
+ }
246
+ }
247
+
248
+ Inputmask.prototype.pasteEvent = function() {
249
+ var that = this
250
+
251
+ setTimeout(function() {
252
+ that.caret(that.checkVal(true))
253
+ }, 0)
254
+ }
255
+
256
+ Inputmask.prototype.clearBuffer = function(start, end) {
257
+ var len = this.mask.length
258
+
259
+ for (var i = start; i < end && i < len; i++) {
260
+ if (this.tests[i])
261
+ this.buffer[i] = this.options.placeholder
262
+ }
263
+ }
264
+
265
+ Inputmask.prototype.writeBuffer = function() {
266
+ return this.$element.val(this.buffer.join('')).val()
267
+ }
268
+
269
+ Inputmask.prototype.checkVal = function(allow) {
270
+ var len = this.mask.length
271
+ //try to place characters where they belong
272
+ var test = this.$element.val()
273
+ var lastMatch = -1
274
+
275
+ for (var i = 0, pos = 0; i < len; i++) {
276
+ if (this.tests[i]) {
277
+ this.buffer[i] = this.options.placeholder
278
+ while (pos++ < test.length) {
279
+ var c = test.charAt(pos - 1)
280
+ if (this.tests[i].test(c)) {
281
+ this.buffer[i] = c
282
+ lastMatch = i
283
+ break
284
+ }
285
+ }
286
+ if (pos > test.length)
287
+ break
288
+ } else if (this.buffer[i] == test.charAt(pos) && i != this.partialPosition) {
289
+ pos++
290
+ lastMatch = i
291
+ }
292
+ }
293
+ if (!allow && lastMatch + 1 < this.partialPosition) {
294
+ this.$element.val("")
295
+ this.clearBuffer(0, len)
296
+ } else if (allow || lastMatch + 1 >= this.partialPosition) {
297
+ this.writeBuffer()
298
+ if (!allow) this.$element.val(this.$element.val().substring(0, lastMatch + 1))
299
+ }
300
+ return (this.partialPosition ? i : this.firstNonMaskPos)
301
+ }
302
+
303
+
304
+ // INPUTMASK PLUGIN DEFINITION
305
+ // ===========================
306
+
307
+ var old = $.fn.inputmask
308
+
309
+ $.fn.inputmask = function (options) {
310
+ return this.each(function () {
311
+ var $this = $(this)
312
+ var data = $this.data('inputmask')
313
+
314
+ if (!data) $this.data('inputmask', (data = new Inputmask(this, options)))
315
+ })
316
+ }
317
+
318
+ $.fn.inputmask.Constructor = Inputmask
319
+
320
+
321
+ // INPUTMASK NO CONFLICT
322
+ // ====================
323
+
324
+ $.fn.inputmask.noConflict = function () {
325
+ $.fn.inputmask = old
326
+ return this
327
+ }
328
+
329
+
330
+ // INPUTMASK DATA-API
331
+ // ==================
332
+
333
+ $(document).on('focus.bs.inputmask.data-api', '[data-mask]', function (e) {
334
+ var $this = $(this)
335
+ if ($this.data('inputmask')) return
336
+ $this.inputmask($this.data())
337
+ })
338
+
339
+ }(window.jQuery);
@@ -0,0 +1,144 @@
1
+ +function ($) {
2
+ 'use strict';
3
+
4
+ // SCROLLSPY CLASS DEFINITION
5
+ // ==========================
6
+
7
+ function ScrollSpy(element, options) {
8
+ var href
9
+ var process = $.proxy(this.process, this)
10
+
11
+ this.$element = $(element).is('body') ? $(window) : $(element)
12
+ this.$body = $('body')
13
+ this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
14
+ this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
15
+ this.selector = (this.options.target
16
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
17
+ || '') + ' .nav li > a'
18
+ this.offsets = $([])
19
+ this.targets = $([])
20
+ this.activeTarget = null
21
+
22
+ this.refresh()
23
+ this.process()
24
+ }
25
+
26
+ ScrollSpy.DEFAULTS = {
27
+ offset: 10
28
+ }
29
+
30
+ ScrollSpy.prototype.refresh = function () {
31
+ var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
32
+
33
+ this.offsets = $([])
34
+ this.targets = $([])
35
+
36
+ var self = this
37
+ var $targets = this.$body
38
+ .find(this.selector)
39
+ .map(function () {
40
+ var $el = $(this)
41
+ var href = $el.data('target') || $el.attr('href')
42
+ var $href = /^#./.test(href) && $(href)
43
+
44
+ return ($href
45
+ && $href.length
46
+ && $href.is(':visible')
47
+ && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
48
+ })
49
+ .sort(function (a, b) { return a[0] - b[0] })
50
+ .each(function () {
51
+ self.offsets.push(this[0])
52
+ self.targets.push(this[1])
53
+ })
54
+ }
55
+
56
+ ScrollSpy.prototype.process = function () {
57
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
58
+ var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
59
+ var maxScroll = scrollHeight - this.$scrollElement.height()
60
+ var offsets = this.offsets
61
+ var targets = this.targets
62
+ var activeTarget = this.activeTarget
63
+ var i
64
+
65
+ if (scrollTop >= maxScroll) {
66
+ return activeTarget != (i = targets.last()[0]) && this.activate(i)
67
+ }
68
+
69
+ if (activeTarget && scrollTop <= offsets[0]) {
70
+ return activeTarget != (i = targets[0]) && this.activate(i)
71
+ }
72
+
73
+ for (i = offsets.length; i--;) {
74
+ activeTarget != targets[i]
75
+ && scrollTop >= offsets[i]
76
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
77
+ && this.activate( targets[i] )
78
+ }
79
+ }
80
+
81
+ ScrollSpy.prototype.activate = function (target) {
82
+ this.activeTarget = target
83
+
84
+ $(this.selector)
85
+ .parentsUntil(this.options.target, '.active')
86
+ .removeClass('active')
87
+
88
+ var selector = this.selector +
89
+ '[data-target="' + target + '"],' +
90
+ this.selector + '[href="' + target + '"]'
91
+
92
+ var active = $(selector)
93
+ .parents('li')
94
+ .addClass('active')
95
+
96
+ if (active.parent('.dropdown-menu').length) {
97
+ active = active
98
+ .closest('li.dropdown')
99
+ .addClass('active')
100
+ }
101
+
102
+ active.trigger('activate.bs.scrollspy')
103
+ }
104
+
105
+
106
+ // SCROLLSPY PLUGIN DEFINITION
107
+ // ===========================
108
+
109
+ var old = $.fn.scrollspy
110
+
111
+ $.fn.scrollspy = function (option) {
112
+ return this.each(function () {
113
+ var $this = $(this)
114
+ var data = $this.data('bs.scrollspy')
115
+ var options = typeof option == 'object' && option
116
+
117
+ if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
118
+ if (typeof option == 'string') data[option]()
119
+ })
120
+ }
121
+
122
+ $.fn.scrollspy.Constructor = ScrollSpy
123
+
124
+
125
+ // SCROLLSPY NO CONFLICT
126
+ // =====================
127
+
128
+ $.fn.scrollspy.noConflict = function () {
129
+ $.fn.scrollspy = old
130
+ return this
131
+ }
132
+
133
+
134
+ // SCROLLSPY DATA-API
135
+ // ==================
136
+
137
+ $(window).on('load', function () {
138
+ $('[data-spy="scroll"]').each(function () {
139
+ var $spy = $(this)
140
+ $spy.scrollspy($spy.data())
141
+ })
142
+ })
143
+
144
+ }(jQuery);