Guest User

Off-Canvas Menu HTML

a guest
Apr 7th, 2016
474
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <nav id="myNavmenu" class="navmenu navmenu-default navmenu-fixed-left offcanvas" role="navigation">
  2. <?php
  3. theme_hmenu_3();
  4. ?>
  5. </nav>
  6. <div class="navbar navbar-default navbar-fixed-top22">
  7. <button type="button" class="navbar-toggle" data-toggle="offcanvas" data-target="#myNavmenu" data-canvas="body">
  8. <span class="icon-bar"></span>
  9. <span class="icon-bar"></span>
  10. <span class="icon-bar"></span>
  11. </button>
  12. </div>
  13.  
  14. <script type="text/javascript">
  15. (function( $ ) {
  16. "use strict";
  17.  
  18. $(function () {
  19. /*!
  20. * Jasny Bootstrap v3.1.3 (http://jasny.github.io/bootstrap)
  21. * Copyright 2012-2014 Arnold Daniels
  22. * Licensed under Apache-2.0 (https://github.com/jasny/bootstrap/blob/master/LICENSE)
  23. */
  24.  
  25. if (typeof jQuery === 'undefined') { throw new Error('Jasny Bootstrap\'s JavaScript requires jQuery') }
  26.  
  27. /* ========================================================================
  28. * Bootstrap: transition.js v3.1.3
  29. * http://getbootstrap.com/javascript/#transitions
  30. * ========================================================================
  31. * Copyright 2011-2014 Twitter, Inc.
  32. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  33. * ======================================================================== */
  34.  
  35.  
  36. +function ($) {
  37. 'use strict';
  38.  
  39. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  40. // ============================================================
  41.  
  42. function transitionEnd() {
  43. var el = document.createElement('bootstrap')
  44.  
  45. var transEndEventNames = {
  46. WebkitTransition : 'webkitTransitionEnd',
  47. MozTransition : 'transitionend',
  48. OTransition : 'oTransitionEnd otransitionend',
  49. transition : 'transitionend'
  50. }
  51.  
  52. for (var name in transEndEventNames) {
  53. if (el.style[name] !== undefined) {
  54. return { end: transEndEventNames[name] }
  55. }
  56. }
  57.  
  58. return false // explicit for ie8 ( ._.)
  59. }
  60.  
  61. if ($.support.transition !== undefined) return // Prevent conflict with Twitter Bootstrap
  62.  
  63. // http://blog.alexmaccaw.com/css-transitions
  64. $.fn.emulateTransitionEnd = function (duration) {
  65. var called = false, $el = this
  66. $(this).one($.support.transition.end, function () { called = true })
  67. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  68. setTimeout(callback, duration)
  69. return this
  70. }
  71.  
  72. $(function () {
  73. $.support.transition = transitionEnd()
  74. })
  75.  
  76. }(window.jQuery);
  77.  
  78. /* ========================================================================
  79. * Bootstrap: offcanvas.js v3.1.3
  80. * http://jasny.github.io/bootstrap/javascript/#offcanvas
  81. * ========================================================================
  82. * Copyright 2013-2014 Arnold Daniels
  83. *
  84. * Licensed under the Apache License, Version 2.0 (the "License")
  85. * you may not use this file except in compliance with the License.
  86. * You may obtain a copy of the License at
  87. *
  88. * http://www.apache.org/licenses/LICENSE-2.0
  89. *
  90. * Unless required by applicable law or agreed to in writing, software
  91. * distributed under the License is distributed on an "AS IS" BASIS,
  92. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  93. * See the License for the specific language governing permissions and
  94. * limitations under the License.
  95. * ======================================================================== */
  96.  
  97. +function ($) { "use strict";
  98.  
  99. // OFFCANVAS PUBLIC CLASS DEFINITION
  100. // =================================
  101.  
  102. var OffCanvas = function (element, options) {
  103. this.$element = $(element)
  104. this.options = $.extend({}, OffCanvas.DEFAULTS, options)
  105. this.state = null
  106. this.placement = null
  107.  
  108. if (this.options.recalc) {
  109. this.calcClone()
  110. $(window).on('resize', $.proxy(this.recalc, this))
  111. }
  112.  
  113. if (this.options.autohide)
  114. $(document).on('click', $.proxy(this.autohide, this))
  115.  
  116. if (this.options.toggle) this.toggle()
  117.  
  118. if (this.options.disablescrolling) {
  119. this.options.disableScrolling = this.options.disablescrolling
  120. delete this.options.disablescrolling
  121. }
  122. }
  123.  
  124. OffCanvas.DEFAULTS = {
  125. toggle: true,
  126. placement: 'auto',
  127. autohide: true,
  128. recalc: true,
  129. disableScrolling: true
  130. }
  131.  
  132. OffCanvas.prototype.offset = function () {
  133. switch (this.placement) {
  134. case 'left':
  135. case 'right': return this.$element.outerWidth()
  136. case 'top':
  137. case 'bottom': return this.$element.outerHeight()
  138. }
  139. }
  140.  
  141. OffCanvas.prototype.calcPlacement = function () {
  142. if (this.options.placement !== 'auto') {
  143. this.placement = this.options.placement
  144. return
  145. }
  146.  
  147. if (!this.$element.hasClass('in')) {
  148. this.$element.css('visiblity', 'hidden !important').addClass('in')
  149. }
  150.  
  151. var horizontal = $(window).width() / this.$element.width()
  152. var vertical = $(window).height() / this.$element.height()
  153.  
  154. var element = this.$element
  155. function ab(a, b) {
  156. if (element.css(b) === 'auto') return a
  157. if (element.css(a) === 'auto') return b
  158.  
  159. var size_a = parseInt(element.css(a), 10)
  160. var size_b = parseInt(element.css(b), 10)
  161.  
  162. return size_a > size_b ? b : a
  163. }
  164.  
  165. this.placement = horizontal >= vertical ? ab('left', 'right') : ab('top', 'bottom')
  166.  
  167. if (this.$element.css('visibility') === 'hidden !important') {
  168. this.$element.removeClass('in').css('visiblity', '')
  169. }
  170. }
  171.  
  172. OffCanvas.prototype.opposite = function (placement) {
  173. switch (placement) {
  174. case 'top': return 'bottom'
  175. case 'left': return 'right'
  176. case 'bottom': return 'top'
  177. case 'right': return 'left'
  178. }
  179. }
  180.  
  181. OffCanvas.prototype.getCanvasElements = function() {
  182. // Return a set containing the canvas plus all fixed elements
  183. var canvas = this.options.canvas ? $(this.options.canvas) : this.$element
  184.  
  185. var fixed_elements = canvas.find('*').filter(function() {
  186. return $(this).css('position') === 'fixed'
  187. }).not(this.options.exclude)
  188.  
  189. return canvas.add(fixed_elements)
  190. }
  191.  
  192. OffCanvas.prototype.slide = function (elements, offset, callback) {
  193. // Use jQuery animation if CSS transitions aren't supported
  194. if (!$.support.transition) {
  195. var anim = {}
  196. anim[this.placement] = "+=" + offset
  197. return elements.animate(anim, 350, callback)
  198. }
  199.  
  200. var placement = this.placement
  201. var opposite = this.opposite(placement)
  202.  
  203. elements.each(function() {
  204. if ($(this).css(placement) !== 'auto')
  205. $(this).css(placement, (parseInt($(this).css(placement), 10) || 0) + offset)
  206.  
  207. if ($(this).css(opposite) !== 'auto')
  208. $(this).css(opposite, (parseInt($(this).css(opposite), 10) || 0) - offset)
  209. })
  210.  
  211. this.$element
  212. .one($.support.transition.end, callback)
  213. .emulateTransitionEnd(350)
  214. }
  215.  
  216. OffCanvas.prototype.disableScrolling = function() {
  217. var bodyWidth = $('body').width()
  218. var prop = 'padding-' + this.opposite(this.placement)
  219.  
  220. if ($('body').data('offcanvas-style') === undefined) {
  221. $('body').data('offcanvas-style', $('body').attr('style') || '')
  222. }
  223.  
  224. $('body').css('overflow', 'hidden')
  225.  
  226. if ($('body').width() > bodyWidth) {
  227. var padding = parseInt($('body').css(prop), 10) + $('body').width() - bodyWidth
  228.  
  229. setTimeout(function() {
  230. $('body').css(prop, padding)
  231. }, 1)
  232. }
  233. }
  234.  
  235. OffCanvas.prototype.show = function () {
  236. if (this.state) return
  237.  
  238. var startEvent = $.Event('show.bs.offcanvas')
  239. this.$element.trigger(startEvent)
  240. if (startEvent.isDefaultPrevented()) return
  241.  
  242. this.state = 'slide-in'
  243. this.calcPlacement();
  244.  
  245. var elements = this.getCanvasElements()
  246. var placement = this.placement
  247. var opposite = this.opposite(placement)
  248. var offset = this.offset()
  249.  
  250. if (elements.index(this.$element) !== -1) {
  251. $(this.$element).data('offcanvas-style', $(this.$element).attr('style') || '')
  252. this.$element.css(placement, -1 * offset)
  253. this.$element.css(placement); // Workaround: Need to get the CSS property for it to be applied before the next line of code
  254. }
  255.  
  256. elements.addClass('canvas-sliding').each(function() {
  257. if ($(this).data('offcanvas-style') === undefined) $(this).data('offcanvas-style', $(this).attr('style') || '')
  258. if ($(this).css('position') === 'static') $(this).css('position', 'relative')
  259. if (($(this).css(placement) === 'auto' || $(this).css(placement) === '0px') &&
  260. ($(this).css(opposite) === 'auto' || $(this).css(opposite) === '0px')) {
  261. $(this).css(placement, 0)
  262. }
  263. })
  264.  
  265. if (this.options.disableScrolling) this.disableScrolling()
  266.  
  267. var complete = function () {
  268. if (this.state != 'slide-in') return
  269.  
  270. this.state = 'slid'
  271.  
  272. elements.removeClass('canvas-sliding').addClass('canvas-slid')
  273. this.$element.trigger('shown.bs.offcanvas')
  274. }
  275.  
  276. setTimeout($.proxy(function() {
  277. this.$element.addClass('in')
  278. this.slide(elements, offset, $.proxy(complete, this))
  279. }, this), 1)
  280. }
  281.  
  282. OffCanvas.prototype.hide = function (fast) {
  283. if (this.state !== 'slid') return
  284.  
  285. var startEvent = $.Event('hide.bs.offcanvas')
  286. this.$element.trigger(startEvent)
  287. if (startEvent.isDefaultPrevented()) return
  288.  
  289. this.state = 'slide-out'
  290.  
  291. var elements = $('.canvas-slid')
  292. var placement = this.placement
  293. var offset = -1 * this.offset()
  294.  
  295. var complete = function () {
  296. if (this.state != 'slide-out') return
  297.  
  298. this.state = null
  299. this.placement = null
  300.  
  301. this.$element.removeClass('in')
  302.  
  303. elements.removeClass('canvas-sliding')
  304. elements.add(this.$element).add('body').each(function() {
  305. $(this).attr('style', $(this).data('offcanvas-style')).removeData('offcanvas-style')
  306. })
  307.  
  308. this.$element.trigger('hidden.bs.offcanvas')
  309. }
  310.  
  311. elements.removeClass('canvas-slid').addClass('canvas-sliding')
  312.  
  313. setTimeout($.proxy(function() {
  314. this.slide(elements, offset, $.proxy(complete, this))
  315. }, this), 1)
  316. }
  317.  
  318. OffCanvas.prototype.toggle = function () {
  319. if (this.state === 'slide-in' || this.state === 'slide-out') return
  320. this[this.state === 'slid' ? 'hide' : 'show']()
  321. }
  322.  
  323. OffCanvas.prototype.calcClone = function() {
  324. this.$calcClone = this.$element.clone()
  325. .html('')
  326. .addClass('offcanvas-clone').removeClass('in')
  327. .appendTo($('body'))
  328. }
  329.  
  330. OffCanvas.prototype.recalc = function () {
  331. if (this.$calcClone.css('display') === 'none' || (this.state !== 'slid' && this.state !== 'slide-in')) return
  332.  
  333. this.state = null
  334. this.placement = null
  335. var elements = this.getCanvasElements()
  336.  
  337. this.$element.removeClass('in')
  338.  
  339. elements.removeClass('canvas-slid')
  340. elements.add(this.$element).add('body').each(function() {
  341. $(this).attr('style', $(this).data('offcanvas-style')).removeData('offcanvas-style')
  342. })
  343. }
  344.  
  345. OffCanvas.prototype.autohide = function (e) {
  346. if ($(e.target).closest(this.$element).length === 0) this.hide()
  347. }
  348.  
  349. // OFFCANVAS PLUGIN DEFINITION
  350. // ==========================
  351.  
  352. var old = $.fn.offcanvas
  353.  
  354. $.fn.offcanvas = function (option) {
  355. return this.each(function () {
  356. var $this = $(this)
  357. var data = $this.data('bs.offcanvas')
  358. var options = $.extend({}, OffCanvas.DEFAULTS, $this.data(), typeof option === 'object' && option)
  359.  
  360. if (!data) $this.data('bs.offcanvas', (data = new OffCanvas(this, options)))
  361. if (typeof option === 'string') data[option]()
  362. })
  363. }
  364.  
  365. $.fn.offcanvas.Constructor = OffCanvas
  366.  
  367.  
  368. // OFFCANVAS NO CONFLICT
  369. // ====================
  370.  
  371. $.fn.offcanvas.noConflict = function () {
  372. $.fn.offcanvas = old
  373. return this
  374. }
  375.  
  376.  
  377. // OFFCANVAS DATA-API
  378. // =================
  379.  
  380. $(document).on('click.bs.offcanvas.data-api', '[data-toggle=offcanvas]', function (e) {
  381. var $this = $(this), href
  382. var target = $this.attr('data-target')
  383. || e.preventDefault()
  384. || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
  385. var $canvas = $(target)
  386. var data = $canvas.data('bs.offcanvas')
  387. var option = data ? 'toggle' : $this.data()
  388.  
  389. e.stopPropagation()
  390.  
  391. if (data) data.toggle()
  392. else $canvas.offcanvas(option)
  393. })
  394.  
  395. }(window.jQuery);
  396.  
  397. /* ============================================================
  398. * Bootstrap: rowlink.js v3.1.3
  399. * http://jasny.github.io/bootstrap/javascript/#rowlink
  400. * ============================================================
  401. * Copyright 2012-2014 Arnold Daniels
  402. *
  403. * Licensed under the Apache License, Version 2.0 (the "License");
  404. * you may not use this file except in compliance with the License.
  405. * You may obtain a copy of the License at
  406. *
  407. * http://www.apache.org/licenses/LICENSE-2.0
  408. *
  409. * Unless required by applicable law or agreed to in writing, software
  410. * distributed under the License is distributed on an "AS IS" BASIS,
  411. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  412. * See the License for the specific language governing permissions and
  413. * limitations under the License.
  414. * ============================================================ */
  415.  
  416. +function ($) { "use strict";
  417.  
  418. var Rowlink = function (element, options) {
  419. this.$element = $(element)
  420. this.options = $.extend({}, Rowlink.DEFAULTS, options)
  421.  
  422. this.$element.on('click.bs.rowlink', 'td:not(.rowlink-skip)', $.proxy(this.click, this))
  423. }
  424.  
  425. Rowlink.DEFAULTS = {
  426. target: "a"
  427. }
  428.  
  429. Rowlink.prototype.click = function(e) {
  430. var target = $(e.currentTarget).closest('tr').find(this.options.target)[0]
  431. if ($(e.target)[0] === target) return
  432.  
  433. e.preventDefault();
  434.  
  435. if (target.click) {
  436. target.click()
  437. } else if (document.createEvent) {
  438. var evt = document.createEvent("MouseEvents");
  439. evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  440. target.dispatchEvent(evt);
  441. }
  442. }
  443.  
  444.  
  445. // ROWLINK PLUGIN DEFINITION
  446. // ===========================
  447.  
  448. var old = $.fn.rowlink
  449.  
  450. $.fn.rowlink = function (options) {
  451. return this.each(function () {
  452. var $this = $(this)
  453. var data = $this.data('bs.rowlink')
  454. if (!data) $this.data('bs.rowlink', (data = new Rowlink(this, options)))
  455. })
  456. }
  457.  
  458. $.fn.rowlink.Constructor = Rowlink
  459.  
  460.  
  461. // ROWLINK NO CONFLICT
  462. // ====================
  463.  
  464. $.fn.rowlink.noConflict = function () {
  465. $.fn.rowlink = old
  466. return this
  467. }
  468.  
  469.  
  470. // ROWLINK DATA-API
  471. // ==================
  472.  
  473. $(document).on('click.bs.rowlink.data-api', '[data-link="row"]', function (e) {
  474. if ($(e.target).closest('.rowlink-skip').length !== 0) return
  475.  
  476. var $this = $(this)
  477. if ($this.data('bs.rowlink')) return
  478. $this.rowlink($this.data())
  479. $(e.target).trigger('click.bs.rowlink')
  480. })
  481.  
  482. }(window.jQuery);
  483.  
  484. /* ===========================================================
  485. * Bootstrap: inputmask.js v3.1.0
  486. * http://jasny.github.io/bootstrap/javascript/#inputmask
  487. *
  488. * Based on Masked Input plugin by Josh Bush (digitalbush.com)
  489. * ===========================================================
  490. * Copyright 2012-2014 Arnold Daniels
  491. *
  492. * Licensed under the Apache License, Version 2.0 (the "License")
  493. * you may not use this file except in compliance with the License.
  494. * You may obtain a copy of the License at
  495. *
  496. * http://www.apache.org/licenses/LICENSE-2.0
  497. *
  498. * Unless required by applicable law or agreed to in writing, software
  499. * distributed under the License is distributed on an "AS IS" BASIS,
  500. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  501. * See the License for the specific language governing permissions and
  502. * limitations under the License.
  503. * ========================================================== */
  504.  
  505. +function ($) { "use strict";
  506.  
  507. var isIphone = (window.orientation !== undefined)
  508. var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
  509. var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
  510.  
  511. // INPUTMASK PUBLIC CLASS DEFINITION
  512. // =================================
  513.  
  514. var Inputmask = function (element, options) {
  515. if (isAndroid) return // No support because caret positioning doesn't work on Android
  516.  
  517. this.$element = $(element)
  518. this.options = $.extend({}, Inputmask.DEFAULTS, options)
  519. this.mask = String(this.options.mask)
  520.  
  521. this.init()
  522. this.listen()
  523.  
  524. this.checkVal() //Perform initial check for existing values
  525. }
  526.  
  527. Inputmask.DEFAULTS = {
  528. mask: "",
  529. placeholder: "_",
  530. definitions: {
  531. '9': "[0-9]",
  532. 'a': "[A-Za-z]",
  533. 'w': "[A-Za-z0-9]",
  534. '*': "."
  535. }
  536. }
  537.  
  538. Inputmask.prototype.init = function() {
  539. var defs = this.options.definitions
  540. var len = this.mask.length
  541.  
  542. this.tests = []
  543. this.partialPosition = this.mask.length
  544. this.firstNonMaskPos = null
  545.  
  546. $.each(this.mask.split(""), $.proxy(function(i, c) {
  547. if (c == '?') {
  548. len--
  549. this.partialPosition = i
  550. } else if (defs[c]) {
  551. this.tests.push(new RegExp(defs[c]))
  552. if (this.firstNonMaskPos === null)
  553. this.firstNonMaskPos = this.tests.length - 1
  554. } else {
  555. this.tests.push(null)
  556. }
  557. }, this))
  558.  
  559. this.buffer = $.map(this.mask.split(""), $.proxy(function(c, i) {
  560. if (c != '?') return defs[c] ? this.options.placeholder : c
  561. }, this))
  562.  
  563. this.focusText = this.$element.val()
  564.  
  565. this.$element.data("rawMaskFn", $.proxy(function() {
  566. return $.map(this.buffer, function(c, i) {
  567. return this.tests[i] && c != this.options.placeholder ? c : null
  568. }).join('')
  569. }, this))
  570. }
  571.  
  572. Inputmask.prototype.listen = function() {
  573. if (this.$element.attr("readonly")) return
  574.  
  575. var pasteEventName = (isIE ? 'paste' : 'input') + ".mask"
  576.  
  577. this.$element
  578. .on("unmask.bs.inputmask", $.proxy(this.unmask, this))
  579.  
  580. .on("focus.bs.inputmask", $.proxy(this.focusEvent, this))
  581. .on("blur.bs.inputmask", $.proxy(this.blurEvent, this))
  582.  
  583. .on("keydown.bs.inputmask", $.proxy(this.keydownEvent, this))
  584. .on("keypress.bs.inputmask", $.proxy(this.keypressEvent, this))
  585.  
  586. .on(pasteEventName, $.proxy(this.pasteEvent, this))
  587. }
  588.  
  589. //Helper Function for Caret positioning
  590. Inputmask.prototype.caret = function(begin, end) {
  591. if (this.$element.length === 0) return
  592. if (typeof begin == 'number') {
  593. end = (typeof end == 'number') ? end : begin
  594. return this.$element.each(function() {
  595. if (this.setSelectionRange) {
  596. this.setSelectionRange(begin, end)
  597. } else if (this.createTextRange) {
  598. var range = this.createTextRange()
  599. range.collapse(true)
  600. range.moveEnd('character', end)
  601. range.moveStart('character', begin)
  602. range.select()
  603. }
  604. })
  605. } else {
  606. if (this.$element[0].setSelectionRange) {
  607. begin = this.$element[0].selectionStart
  608. end = this.$element[0].selectionEnd
  609. } else if (document.selection && document.selection.createRange) {
  610. var range = document.selection.createRange()
  611. begin = 0 - range.duplicate().moveStart('character', -100000)
  612. end = begin + range.text.length
  613. }
  614. return {
  615. begin: begin,
  616. end: end
  617. }
  618. }
  619. }
  620.  
  621. Inputmask.prototype.seekNext = function(pos) {
  622. var len = this.mask.length
  623. while (++pos <= len && !this.tests[pos]);
  624.  
  625. return pos
  626. }
  627.  
  628. Inputmask.prototype.seekPrev = function(pos) {
  629. while (--pos >= 0 && !this.tests[pos]);
  630.  
  631. return pos
  632. }
  633.  
  634. Inputmask.prototype.shiftL = function(begin,end) {
  635. var len = this.mask.length
  636.  
  637. if (begin < 0) return
  638.  
  639. for (var i = begin, j = this.seekNext(end); i < len; i++) {
  640. if (this.tests[i]) {
  641. if (j < len && this.tests[i].test(this.buffer[j])) {
  642. this.buffer[i] = this.buffer[j]
  643. this.buffer[j] = this.options.placeholder
  644. } else
  645. break
  646. j = this.seekNext(j)
  647. }
  648. }
  649. this.writeBuffer()
  650. this.caret(Math.max(this.firstNonMaskPos, begin))
  651. }
  652.  
  653. Inputmask.prototype.shiftR = function(pos) {
  654. var len = this.mask.length
  655.  
  656. for (var i = pos, c = this.options.placeholder; i < len; i++) {
  657. if (this.tests[i]) {
  658. var j = this.seekNext(i)
  659. var t = this.buffer[i]
  660. this.buffer[i] = c
  661. if (j < len && this.tests[j].test(t))
  662. c = t
  663. else
  664. break
  665. }
  666. }
  667. },
  668.  
  669. Inputmask.prototype.unmask = function() {
  670. this.$element
  671. .unbind(".mask")
  672. .removeData("inputmask")
  673. }
  674.  
  675. Inputmask.prototype.focusEvent = function() {
  676. this.focusText = this.$element.val()
  677. var len = this.mask.length
  678. var pos = this.checkVal()
  679. this.writeBuffer()
  680.  
  681. var that = this
  682. var moveCaret = function() {
  683. if (pos == len)
  684. that.caret(0, pos)
  685. else
  686. that.caret(pos)
  687. }
  688.  
  689. moveCaret()
  690. setTimeout(moveCaret, 50)
  691. }
  692.  
  693. Inputmask.prototype.blurEvent = function() {
  694. this.checkVal()
  695. if (this.$element.val() !== this.focusText)
  696. this.$element.trigger('change')
  697. }
  698.  
  699. Inputmask.prototype.keydownEvent = function(e) {
  700. var k = e.which
  701.  
  702. //backspace, delete, and escape get special treatment
  703. if (k == 8 || k == 46 || (isIphone && k == 127)) {
  704. var pos = this.caret(),
  705. begin = pos.begin,
  706. end = pos.end
  707.  
  708. if (end - begin === 0) {
  709. begin = k != 46 ? this.seekPrev(begin) : (end = this.seekNext(begin - 1))
  710. end = k == 46 ? this.seekNext(end) : end
  711. }
  712. this.clearBuffer(begin, end)
  713. this.shiftL(begin, end - 1)
  714.  
  715. return false
  716. } else if (k == 27) {//escape
  717. this.$element.val(this.focusText)
  718. this.caret(0, this.checkVal())
  719. return false
  720. }
  721. }
  722.  
  723. Inputmask.prototype.keypressEvent = function(e) {
  724. var len = this.mask.length
  725.  
  726. var k = e.which,
  727. pos = this.caret()
  728.  
  729. if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
  730. return true
  731. } else if (k) {
  732. if (pos.end - pos.begin !== 0) {
  733. this.clearBuffer(pos.begin, pos.end)
  734. this.shiftL(pos.begin, pos.end - 1)
  735. }
  736.  
  737. var p = this.seekNext(pos.begin - 1)
  738. if (p < len) {
  739. var c = String.fromCharCode(k)
  740. if (this.tests[p].test(c)) {
  741. this.shiftR(p)
  742. this.buffer[p] = c
  743. this.writeBuffer()
  744. var next = this.seekNext(p)
  745. this.caret(next)
  746. }
  747. }
  748. return false
  749. }
  750. }
  751.  
  752. Inputmask.prototype.pasteEvent = function() {
  753. var that = this
  754.  
  755. setTimeout(function() {
  756. that.caret(that.checkVal(true))
  757. }, 0)
  758. }
  759.  
  760. Inputmask.prototype.clearBuffer = function(start, end) {
  761. var len = this.mask.length
  762.  
  763. for (var i = start; i < end && i < len; i++) {
  764. if (this.tests[i])
  765. this.buffer[i] = this.options.placeholder
  766. }
  767. }
  768.  
  769. Inputmask.prototype.writeBuffer = function() {
  770. return this.$element.val(this.buffer.join('')).val()
  771. }
  772.  
  773. Inputmask.prototype.checkVal = function(allow) {
  774. var len = this.mask.length
  775. //try to place characters where they belong
  776. var test = this.$element.val()
  777. var lastMatch = -1
  778.  
  779. for (var i = 0, pos = 0; i < len; i++) {
  780. if (this.tests[i]) {
  781. this.buffer[i] = this.options.placeholder
  782. while (pos++ < test.length) {
  783. var c = test.charAt(pos - 1)
  784. if (this.tests[i].test(c)) {
  785. this.buffer[i] = c
  786. lastMatch = i
  787. break
  788. }
  789. }
  790. if (pos > test.length)
  791. break
  792. } else if (this.buffer[i] == test.charAt(pos) && i != this.partialPosition) {
  793. pos++
  794. lastMatch = i
  795. }
  796. }
  797. if (!allow && lastMatch + 1 < this.partialPosition) {
  798. this.$element.val("")
  799. this.clearBuffer(0, len)
  800. } else if (allow || lastMatch + 1 >= this.partialPosition) {
  801. this.writeBuffer()
  802. if (!allow) this.$element.val(this.$element.val().substring(0, lastMatch + 1))
  803. }
  804. return (this.partialPosition ? i : this.firstNonMaskPos)
  805. }
  806.  
  807.  
  808. // INPUTMASK PLUGIN DEFINITION
  809. // ===========================
  810.  
  811. var old = $.fn.inputmask
  812.  
  813. $.fn.inputmask = function (options) {
  814. return this.each(function () {
  815. var $this = $(this)
  816. var data = $this.data('bs.inputmask')
  817.  
  818. if (!data) $this.data('bs.inputmask', (data = new Inputmask(this, options)))
  819. })
  820. }
  821.  
  822. $.fn.inputmask.Constructor = Inputmask
  823.  
  824.  
  825. // INPUTMASK NO CONFLICT
  826. // ====================
  827.  
  828. $.fn.inputmask.noConflict = function () {
  829. $.fn.inputmask = old
  830. return this
  831. }
  832.  
  833.  
  834. // INPUTMASK DATA-API
  835. // ==================
  836.  
  837. $(document).on('focus.bs.inputmask.data-api', '[data-mask]', function (e) {
  838. var $this = $(this)
  839. if ($this.data('bs.inputmask')) return
  840. $this.inputmask($this.data())
  841. })
  842.  
  843. }(window.jQuery);
  844.  
  845. /* ===========================================================
  846. * Bootstrap: fileinput.js v3.1.3
  847. * http://jasny.github.com/bootstrap/javascript/#fileinput
  848. * ===========================================================
  849. * Copyright 2012-2014 Arnold Daniels
  850. *
  851. * Licensed under the Apache License, Version 2.0 (the "License")
  852. * you may not use this file except in compliance with the License.
  853. * You may obtain a copy of the License at
  854. *
  855. * http://www.apache.org/licenses/LICENSE-2.0
  856. *
  857. * Unless required by applicable law or agreed to in writing, software
  858. * distributed under the License is distributed on an "AS IS" BASIS,
  859. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  860. * See the License for the specific language governing permissions and
  861. * limitations under the License.
  862. * ========================================================== */
  863.  
  864. +function ($) { "use strict";
  865.  
  866. var isIE = window.navigator.appName == 'Microsoft Internet Explorer'
  867.  
  868. // FILEUPLOAD PUBLIC CLASS DEFINITION
  869. // =================================
  870.  
  871. var Fileinput = function (element, options) {
  872. this.$element = $(element)
  873.  
  874. this.$input = this.$element.find(':file')
  875. if (this.$input.length === 0) return
  876.  
  877. this.name = this.$input.attr('name') || options.name
  878.  
  879. this.$hidden = this.$element.find('input[type=hidden][name="' + this.name + '"]')
  880. if (this.$hidden.length === 0) {
  881. this.$hidden = $('<input type="hidden">').insertBefore(this.$input)
  882. }
  883.  
  884. this.$preview = this.$element.find('.fileinput-preview')
  885. var height = this.$preview.css('height')
  886. if (this.$preview.css('display') !== 'inline' && height !== '0px' && height !== 'none') {
  887. this.$preview.css('line-height', height)
  888. }
  889.  
  890. this.original = {
  891. exists: this.$element.hasClass('fileinput-exists'),
  892. preview: this.$preview.html(),
  893. hiddenVal: this.$hidden.val()
  894. }
  895.  
  896. this.listen()
  897. }
  898.  
  899. Fileinput.prototype.listen = function() {
  900. this.$input.on('change.bs.fileinput', $.proxy(this.change, this))
  901. $(this.$input[0].form).on('reset.bs.fileinput', $.proxy(this.reset, this))
  902.  
  903. this.$element.find('[data-trigger="fileinput"]').on('click.bs.fileinput', $.proxy(this.trigger, this))
  904. this.$element.find('[data-dismiss="fileinput"]').on('click.bs.fileinput', $.proxy(this.clear, this))
  905. },
  906.  
  907. Fileinput.prototype.change = function(e) {
  908. var files = e.target.files === undefined ? (e.target && e.target.value ? [{ name: e.target.value.replace(/^.+\\/, '')}] : []) : e.target.files
  909.  
  910. e.stopPropagation()
  911.  
  912. if (files.length === 0) {
  913. this.clear()
  914. return
  915. }
  916.  
  917. this.$hidden.val('')
  918. this.$hidden.attr('name', '')
  919. this.$input.attr('name', this.name)
  920.  
  921. var file = files[0]
  922.  
  923. 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") {
  924. var reader = new FileReader()
  925. var preview = this.$preview
  926. var element = this.$element
  927.  
  928. reader.onload = function(re) {
  929. var $img = $('<img>')
  930. $img[0].src = re.target.result
  931. files[0].result = re.target.result
  932.  
  933. element.find('.fileinput-filename').text(file.name)
  934.  
  935. // if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account
  936. 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))
  937.  
  938. preview.html($img)
  939. element.addClass('fileinput-exists').removeClass('fileinput-new')
  940.  
  941. element.trigger('change.bs.fileinput', files)
  942. }
  943.  
  944. reader.readAsDataURL(file)
  945. } else {
  946. this.$element.find('.fileinput-filename').text(file.name)
  947. this.$preview.text(file.name)
  948.  
  949. this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
  950.  
  951. this.$element.trigger('change.bs.fileinput')
  952. }
  953. },
  954.  
  955. Fileinput.prototype.clear = function(e) {
  956. if (e) e.preventDefault()
  957.  
  958. this.$hidden.val('')
  959. this.$hidden.attr('name', this.name)
  960. this.$input.attr('name', '')
  961.  
  962. //ie8+ doesn't support changing the value of input with type=file so clone instead
  963. if (isIE) {
  964. var inputClone = this.$input.clone(true);
  965. this.$input.after(inputClone);
  966. this.$input.remove();
  967. this.$input = inputClone;
  968. } else {
  969. this.$input.val('')
  970. }
  971.  
  972. this.$preview.html('')
  973. this.$element.find('.fileinput-filename').text('')
  974. this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
  975.  
  976. if (e !== undefined) {
  977. this.$input.trigger('change')
  978. this.$element.trigger('clear.bs.fileinput')
  979. }
  980. },
  981.  
  982. Fileinput.prototype.reset = function() {
  983. this.clear()
  984.  
  985. this.$hidden.val(this.original.hiddenVal)
  986. this.$preview.html(this.original.preview)
  987. this.$element.find('.fileinput-filename').text('')
  988.  
  989. if (this.original.exists) this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
  990. else this.$element.addClass('fileinput-new').removeClass('fileinput-exists')
  991.  
  992. this.$element.trigger('reset.bs.fileinput')
  993. },
  994.  
  995. Fileinput.prototype.trigger = function(e) {
  996. this.$input.trigger('click')
  997. e.preventDefault()
  998. }
  999.  
  1000.  
  1001. // FILEUPLOAD PLUGIN DEFINITION
  1002. // ===========================
  1003.  
  1004. var old = $.fn.fileinput
  1005.  
  1006. $.fn.fileinput = function (options) {
  1007. return this.each(function () {
  1008. var $this = $(this),
  1009. data = $this.data('bs.fileinput')
  1010. if (!data) $this.data('bs.fileinput', (data = new Fileinput(this, options)))
  1011. if (typeof options == 'string') data[options]()
  1012. })
  1013. }
  1014.  
  1015. $.fn.fileinput.Constructor = Fileinput
  1016.  
  1017.  
  1018. // FILEINPUT NO CONFLICT
  1019. // ====================
  1020.  
  1021. $.fn.fileinput.noConflict = function () {
  1022. $.fn.fileinput = old
  1023. return this
  1024. }
  1025.  
  1026.  
  1027. // FILEUPLOAD DATA-API
  1028. // ==================
  1029.  
  1030. $(document).on('click.fileinput.data-api', '[data-provides="fileinput"]', function (e) {
  1031. var $this = $(this)
  1032. if ($this.data('bs.fileinput')) return
  1033. $this.fileinput($this.data())
  1034.  
  1035. var $target = $(e.target).closest('[data-dismiss="fileinput"],[data-trigger="fileinput"]');
  1036. if ($target.length > 0) {
  1037. e.preventDefault()
  1038. $target.trigger('click.bs.fileinput')
  1039. }
  1040. })
  1041.  
  1042. }(window.jQuery);
  1043.  
  1044. })
  1045.  
  1046. }(jQuery));
  1047. </script>
RAW Paste Data