global.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. !function ($) {
  2. "use strict"; // jshint ;_;
  3. /* MODAL CLASS DEFINITION
  4. * ====================== */
  5. var Modal = function (element, options) {
  6. this.options = options
  7. this.$element = $(element)
  8. .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
  9. this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
  10. }
  11. Modal.prototype = {
  12. constructor: Modal
  13. , toggle: function () {
  14. return this[!this.isShown ? 'show' : 'hide']()
  15. }
  16. , show: function () {
  17. var that = this
  18. , e = $.Event('show')
  19. this.$element.trigger(e)
  20. if (this.isShown || e.isDefaultPrevented()) return
  21. this.isShown = true
  22. this.escape()
  23. this.backdrop(function () {
  24. var transition = $.support.transition && that.$element.hasClass('fade')
  25. if (!that.$element.parent().length) {
  26. that.$element.appendTo(document.body) //don't move modals dom position
  27. }
  28. that.$element.show()
  29. if (transition) {
  30. that.$element[0].offsetWidth // force reflow
  31. }
  32. that.$element
  33. .addClass('in')
  34. .attr('aria-hidden', false)
  35. that.enforceFocus()
  36. transition ?
  37. that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
  38. that.$element.focus().trigger('shown')
  39. })
  40. }
  41. , hide: function (e) {
  42. e && e.preventDefault()
  43. var that = this
  44. e = $.Event('hide')
  45. this.$element.trigger(e)
  46. if (!this.isShown || e.isDefaultPrevented()) return
  47. this.isShown = false
  48. this.escape()
  49. $(document).off('focusin.modal')
  50. this.$element
  51. .removeClass('in')
  52. .attr('aria-hidden', true)
  53. $.support.transition && this.$element.hasClass('fade') ?
  54. this.hideWithTransition() :
  55. this.hideModal()
  56. }
  57. , enforceFocus: function () {
  58. var that = this
  59. $(document).on('focusin.modal', function (e) {
  60. if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
  61. that.$element.focus()
  62. }
  63. })
  64. }
  65. , escape: function () {
  66. var that = this
  67. if (this.isShown && this.options.keyboard) {
  68. this.$element.on('keyup.dismiss.modal', function ( e ) {
  69. e.which == 27 && that.hide()
  70. })
  71. } else if (!this.isShown) {
  72. this.$element.off('keyup.dismiss.modal')
  73. }
  74. }
  75. , hideWithTransition: function () {
  76. var that = this
  77. , timeout = setTimeout(function () {
  78. that.$element.off($.support.transition.end)
  79. that.hideModal()
  80. }, 500)
  81. this.$element.one($.support.transition.end, function () {
  82. clearTimeout(timeout)
  83. that.hideModal()
  84. })
  85. }
  86. , hideModal: function () {
  87. var that = this
  88. this.$element.hide()
  89. this.backdrop(function () {
  90. that.removeBackdrop()
  91. that.$element.trigger('hidden')
  92. })
  93. }
  94. , removeBackdrop: function () {
  95. this.$backdrop && this.$backdrop.remove()
  96. this.$backdrop = null
  97. }
  98. , backdrop: function (callback) {
  99. var that = this
  100. , animate = this.$element.hasClass('fade') ? 'fade' : ''
  101. if (this.isShown && this.options.backdrop) {
  102. var doAnimate = $.support.transition && animate
  103. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
  104. .appendTo(document.body)
  105. this.$backdrop.click(
  106. this.options.backdrop == 'static' ?
  107. $.proxy(this.$element[0].focus, this.$element[0])
  108. : $.proxy(this.hide, this)
  109. )
  110. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  111. this.$backdrop.addClass('in')
  112. if (!callback) return
  113. doAnimate ?
  114. this.$backdrop.one($.support.transition.end, callback) :
  115. callback()
  116. } else if (!this.isShown && this.$backdrop) {
  117. this.$backdrop.removeClass('in')
  118. $.support.transition && this.$element.hasClass('fade')?
  119. this.$backdrop.one($.support.transition.end, callback) :
  120. callback()
  121. } else if (callback) {
  122. callback()
  123. }
  124. }
  125. }
  126. /* MODAL PLUGIN DEFINITION
  127. * ======================= */
  128. var old = $.fn.modal
  129. $.fn.modal = function (option) {
  130. return this.each(function () {
  131. var $this = $(this)
  132. , data = $this.data('modal')
  133. , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
  134. if (!data) $this.data('modal', (data = new Modal(this, options)))
  135. if (typeof option == 'string') data[option]()
  136. else if (options.show) data.show()
  137. })
  138. }
  139. $.fn.modal.defaults = {
  140. backdrop: true
  141. , keyboard: true
  142. , show: true
  143. }
  144. $.fn.modal.Constructor = Modal
  145. /* MODAL NO CONFLICT
  146. * ================= */
  147. $.fn.modal.noConflict = function () {
  148. $.fn.modal = old
  149. return this
  150. }
  151. /* MODAL DATA-API
  152. * ============== */
  153. $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
  154. var $this = $(this)
  155. , href = $this.attr('href')
  156. , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
  157. , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
  158. e.preventDefault()
  159. $target
  160. .modal(option)
  161. .one('hide', function () {
  162. $this.focus()
  163. })
  164. })
  165. }(window.jQuery);
  166. !function ( $ ) {
  167. "use strict"
  168. /* SCROLLSPY CLASS DEFINITION
  169. * ========================== */
  170. function ScrollSpy( element, options) {
  171. var process = $.proxy(this.process, this)
  172. , $element = $(element).is('body') ? $(window) : $(element)
  173. , href
  174. this.options = $.extend({}, $.fn.scrollspy.defaults, options)
  175. this.$scrollElement = $element.on('scroll.scroll.data-api', process)
  176. this.selector = (this.options.target
  177. || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  178. || '') + ' .nav li > a'
  179. this.$body = $('body').on('click.scroll.data-api', this.selector, process)
  180. this.refresh()
  181. this.process()
  182. }
  183. ScrollSpy.prototype = {
  184. constructor: ScrollSpy
  185. , refresh: function () {
  186. this.targets = this.$body
  187. .find(this.selector)
  188. .map(function () {
  189. var href = $(this).attr('href')
  190. return /^#\w/.test(href) && $(href).length ? href : null
  191. })
  192. this.offsets = $.map(this.targets, function (id) {
  193. return $(id).position().top
  194. })
  195. }
  196. , process: function () {
  197. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  198. , offsets = this.offsets
  199. , targets = this.targets
  200. , activeTarget = this.activeTarget
  201. , i
  202. for (i = offsets.length; i--;) {
  203. activeTarget != targets[i]
  204. && scrollTop >= offsets[i]
  205. && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
  206. && this.activate( targets[i] )
  207. }
  208. }
  209. , activate: function (target) {
  210. var active
  211. this.activeTarget = target
  212. this.$body
  213. .find(this.selector).parent('.active')
  214. .removeClass('active')
  215. active = this.$body
  216. .find(this.selector + '[href="' + target + '"]')
  217. .parent('li')
  218. .addClass('active')
  219. if ( active.parent('.dropdown-menu') ) {
  220. active.closest('li.dropdown').addClass('active')
  221. }
  222. }
  223. }
  224. /* SCROLLSPY PLUGIN DEFINITION
  225. * =========================== */
  226. $.fn.scrollspy = function ( option ) {
  227. return this.each(function () {
  228. var $this = $(this)
  229. , data = $this.data('scrollspy')
  230. , options = typeof option == 'object' && option
  231. if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
  232. if (typeof option == 'string') data[option]()
  233. })
  234. }
  235. $.fn.scrollspy.Constructor = ScrollSpy
  236. $.fn.scrollspy.defaults = {
  237. offset: 10
  238. }
  239. /* SCROLLSPY DATA-API
  240. * ================== */
  241. $(function () {
  242. $('[data-spy="scroll"]').each(function () {
  243. var $spy = $(this)
  244. $spy.scrollspy($spy.data())
  245. })
  246. })
  247. }( window.jQuery );
  248. (function($){
  249. var settings = {
  250. speed: 350 //animation duration
  251. , easing: "linear" //use easing plugin for more options
  252. , padding: 10
  253. , constrain: false
  254. }
  255. , $window = $(window)
  256. , stickyboxes = []
  257. , methods = {
  258. init:function(opts){
  259. settings = $.extend(settings,opts);
  260. return this.each(function () {
  261. var $this = $(this);
  262. setPosition($this);
  263. stickyboxes[stickyboxes.length] = $this;
  264. moveIntoView();
  265. });
  266. }
  267. , remove:function(){
  268. return this.each(function () {
  269. var sticky = this;
  270. $.each(stickyboxes, function (i, $sb) {
  271. if($sb.get(0) === sticky){
  272. reset(null, $sb);
  273. stickyboxes.splice(i, 1);
  274. return false;
  275. }
  276. });
  277. });
  278. }
  279. , destroy: function () {
  280. $.each(stickyboxes, function (i, $sb) {
  281. reset(null, $sb);
  282. });
  283. stickyboxes=[];
  284. $window.unbind("scroll", moveIntoView);
  285. $window.unbind("resize", reset);
  286. return this;
  287. }
  288. };
  289. var moveIntoView = function () {
  290. $.each(stickyboxes, function (i, $sb) {
  291. var $this = $sb
  292. , data = $this.data("stickySB");
  293. if (data) {
  294. var sTop = $window.scrollTop() - data.offs.top
  295. , currOffs = $this.offset()
  296. , origTop = data.orig.offset.top - data.offs.top
  297. , animTo = origTop;
  298. //scrolled down out of view
  299. if (origTop < sTop) {
  300. //make sure to stop inside parent
  301. if ((sTop + settings.padding) > data.offs.bottom)
  302. animTo = data.offs.bottom;
  303. else animTo = sTop + settings.padding;
  304. }
  305. $this
  306. .stop()
  307. .animate(
  308. {top: animTo}
  309. , settings.speed
  310. , settings.easing
  311. );
  312. }
  313. });
  314. }
  315. var setPosition = function ($sb) {
  316. if ($sb) {
  317. var $this = $sb
  318. , $parent = $this.parent()
  319. , parentOffs = $parent.offset()
  320. , currOff = $this.offset()
  321. , data = $this.data("stickySB");
  322. if (!data) {
  323. data = {
  324. offs: {} // our parents offset
  325. , orig: { // cache for original css
  326. top: $this.css("top")
  327. , left: $this.css("left")
  328. , position: $this.css("position")
  329. , marginTop: $this.css("marginTop")
  330. , marginLeft: $this.css("marginLeft")
  331. , offset: $this.offset()
  332. }
  333. }
  334. }
  335. //go up the tree until we find an elem to position from
  336. while (parentOffs && "top" in parentOffs
  337. && $parent.css("position") == "static") {
  338. $parent = $parent.parent();
  339. parentOffs = $parent.offset();
  340. }
  341. if (parentOffs) { // found a postioned ancestor
  342. var padBtm = parseInt($parent.css("paddingBottom"));
  343. padBtm = isNaN(padBtm) ? 0 : padBtm;
  344. data.offs = parentOffs;
  345. data.offs.bottom = settings.constrain ?
  346. Math.abs(($parent.innerHeight() - padBtm) - $this.outerHeight()) :
  347. $(document).height();
  348. }
  349. else data.offs = { // went to far set to doc
  350. top: 0
  351. , left: 0
  352. , bottom: $(document).height()
  353. };
  354. $this.css({
  355. position: "absolute"
  356. , top: Math.floor(currOff.top - data.offs.top) + "px"
  357. , left: Math.floor(currOff.left - data.offs.left) + "px"
  358. , margin: 0
  359. , width: $this.width()
  360. }).data("stickySB", data);
  361. }
  362. }
  363. var reset = function (ev, $toReset) {
  364. var stickies = stickyboxes;
  365. if ($toReset) { // just resetting selected items
  366. stickies = [$toReset];
  367. }
  368. $.each(stickies, function(i, $sb) {
  369. var data = $sb.data("stickySB");
  370. if (data) {
  371. $sb.css({
  372. position: data.orig.position
  373. , marginTop: data.orig.marginTop
  374. , marginLeft: data.orig.marginLeft
  375. , left: data.orig.left
  376. , top: data.orig.top
  377. });
  378. if (!$toReset) { // just resetting
  379. setPosition($sb);
  380. moveIntoView();
  381. }
  382. }
  383. });
  384. }
  385. $window.bind("scroll", moveIntoView);
  386. $window.bind("resize", reset);
  387. $.fn.stickySidebar = function (method) {
  388. if (methods[method]) {
  389. return methods[method].apply(
  390. this
  391. , Array.prototype.slice.call(arguments, 1)
  392. );
  393. } else if (!method || typeof method == "object") {
  394. return methods.init.apply(this, arguments);
  395. }
  396. }
  397. })(jQuery);
  398. (function($,g){var h={},id=1,etid=g+'ETID';$.fn[g]=function(e,f){id++;f=f||this.data(etid)||id;e=e||150;if(f===id)this.data(etid,f);this._hover=this.hover;this.hover=function(c,d){c=c||$.noop;d=d||$.noop;this._hover(function(a){var b=this;clearTimeout(h[f]);h[f]=setTimeout(function(){c.call(b,a)},e)},function(a){var b=this;clearTimeout(h[f]);h[f]=setTimeout(function(){d.call(b,a)},e)});return this};return this};$.fn[g+'Pause']=function(){clearTimeout(this.data(etid));return this};$[g]={get:function(){return id++},pause:function(a){clearTimeout(h[a])}}})(jQuery,'mouseDelay');
  399. function autoFlashHeight(){
  400. $(".newsList").height($(window).height()-296 );$(".contentBg").height($(window).height()-305 );
  401. };
  402. $(window).resize(autoFlashHeight);
  403. $(function(){
  404. $(".videoItem li").hover(function () {
  405. $(this).children(".videoCon").animate({top:'0'},"normal","swing");
  406. },
  407. function () {
  408. $(this).children(".videoCon").animate({top:'110px'},"fast");
  409. }
  410. );
  411. });
  412. $(function(){
  413. $(".trainEntry").hover(function () {
  414. $(this).addClass("shake")
  415. },
  416. function () {
  417. $(this).removeClass("shake")
  418. }
  419. );
  420. $(".trainFormTab a").click(function(){
  421. $(this).addClass("now").siblings().removeClass("now");
  422. $(".trainFormItem > .formEntry ").hide().eq($(".trainFormTab a").index(this)).animate({opacity: 'toggle'},500);});
  423. $(".openAll").click(function(){
  424. $(".mainContact").animate({left:"340px"},"normal").hide();
  425. $(".allContact").show().animate({left:"0"},"normal");
  426. });
  427. $(".closeAll").click(function(){
  428. $(".allContact").hide().animate({left:"450px"},"normal");
  429. $(".mainContact").show().animate({left:"0"},"normal");
  430. });
  431. $(".indexSoft .softEntry").hover(function () {
  432. $(this).addClass("focus").children(".seList").show("fast");
  433. },
  434. function () {
  435. $(this).removeClass("focus").children(".seList").hide();
  436. }
  437. );
  438. $(".contentBottom").mouseDelay(800).hover(function () {
  439. $(this).children(".newsExtra").show().animate({top:"-255px",opacity:"1"});
  440. },
  441. function () {
  442. $(this).children(".newsExtra").animate({top:"-200",opacity:"0"}).fadeOut();
  443. }
  444. );
  445. $('.selectTitle').click(function(){
  446. $(this).siblings(".selectList").fadeToggle();
  447. $(this).toggleClass("focus");
  448. if ($(this).hasClass('focus')) $(this).find('b').html('&#x25B2;').addClass("down")
  449. else $(this).find('b').html('&#x25BC;').removeClass("down")
  450. });
  451. });