voca-main.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  1. /*!
  2. * kontext
  3. * http://lab.hakim.se/kontext
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2013 Hakim El Hattab, http://hakim.se
  7. */
  8. window.kontext = function( container ) {
  9. // Dispatched when the current layer changes
  10. var changed = new kontext.Signal();
  11. // All layers in this instance of kontext
  12. var layers = Array.prototype.slice.call( container.querySelectorAll( '.layer' ) );
  13. // Flag if the browser is capable of handling our fancy transition
  14. var capable = 'WebkitPerspective' in document.body.style ||
  15. 'MozPerspective' in document.body.style ||
  16. 'msPerspective' in document.body.style ||
  17. 'OPerspective' in document.body.style ||
  18. 'perspective' in document.body.style;
  19. if( capable ) {
  20. container.classList.add( 'capable' );
  21. }
  22. // Create dimmer elements to fade out preceding slides
  23. layers.forEach( function( el, i ) {
  24. if( !el.querySelector( '.dimmer' ) ) {
  25. var dimmer = document.createElement( 'div' );
  26. dimmer.className = 'dimmer';
  27. el.appendChild( dimmer );
  28. }
  29. } );
  30. /**
  31. * Transitions to and shows the target layer.
  32. *
  33. * @param target index of layer or layer DOM element
  34. */
  35. function show( target, direction ) {
  36. // Make sure our listing of available layers is up to date
  37. layers = Array.prototype.slice.call( container.querySelectorAll( '.layer' ) );
  38. // Flag to CSS that we're ready to animate transitions
  39. container.classList.add( 'animate' );
  40. // Flag which direction
  41. direction = direction || ( target > getIndex() ? 'right' : 'left' );
  42. // Accept multiple types of targets
  43. if( typeof target === 'string' ) target = parseInt( target );
  44. if( typeof target !== 'number' ) target = getIndex( target );
  45. // Enforce index bounds
  46. target = Math.max( Math.min( target, layers.length ), 0 );
  47. // Only navigate if were able to locate the target
  48. if( layers[ target ] && !layers[ target ].classList.contains( 'show' ) ) {
  49. layers.forEach( function( el, i ) {
  50. el.classList.remove( 'left', 'right' );
  51. el.classList.add( direction );
  52. if( el.classList.contains( 'show' ) ) {
  53. el.classList.remove( 'show' );
  54. el.classList.add( 'hide1' );
  55. }
  56. else {
  57. el.classList.remove( 'hide1' );
  58. }
  59. } );
  60. layers[ target ].classList.add( 'show' );
  61. changed.dispatch( layers[target], target );
  62. }
  63. }
  64. /**
  65. * Shows the previous layer.
  66. */
  67. function prev() {
  68. var index = getIndex() - 1;
  69. show( index >= 0 ? index : layers.length + index, 'left' );
  70. }
  71. /**
  72. * Shows the next layer.
  73. */
  74. function next(callBack) {
  75. show( ( getIndex() + 1 ) % layers.length, 'right' );
  76. if(typeof(callBack)== 'function'){
  77. callBack();
  78. }
  79. }
  80. /**
  81. * Retrieves the index of the current slide.
  82. *
  83. * @param of [optional] layer DOM element which index is
  84. * to be returned
  85. */
  86. function getIndex( of ) {
  87. var index = 0;
  88. layers.forEach( function( layer, i ) {
  89. if( ( of && of == layer ) || ( !of && layer.classList.contains( 'show' ) ) ) {
  90. index = i;
  91. return;
  92. }
  93. } );
  94. return index;
  95. }
  96. /**
  97. * Retrieves the total number of layers.
  98. */
  99. function getTotal() {
  100. return layers.length;
  101. }
  102. // API
  103. return {
  104. show: show,
  105. prev: prev,
  106. next: next,
  107. getIndex: getIndex,
  108. getTotal: getTotal,
  109. changed: changed
  110. };
  111. };
  112. /*!
  113. * jQuery blockUI plugin
  114. * Version 2.66.0-2013.10.09
  115. * Requires jQuery v1.7 or later
  116. *
  117. * Examples at: http://malsup.com/jquery/block/
  118. * Copyright (c) 2007-2013 M. Alsup
  119. * Dual licensed under the MIT and GPL licenses:
  120. * http://www.opensource.org/licenses/mit-license.php
  121. * http://www.gnu.org/licenses/gpl.html
  122. *
  123. * Thanks to Amir-Hossein Sobhi for some excellent contributions!
  124. */
  125. ;(function() {
  126. /*jshint eqeqeq:false curly:false latedef:false */
  127. "use strict";
  128. function setup($) {
  129. $.fn._fadeIn = $.fn.fadeIn;
  130. var noOp = $.noop || function() {};
  131. // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
  132. // confusing userAgent strings on Vista)
  133. var msie = /MSIE/.test(navigator.userAgent);
  134. var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
  135. var mode = document.documentMode || 0;
  136. var setExpr = $.isFunction( document.createElement('div').style.setExpression );
  137. // global $ methods for blocking/unblocking the entire page
  138. $.blockUI = function(opts) { install(window, opts); };
  139. $.unblockUI = function(opts) { remove(window, opts); };
  140. // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
  141. $.growlUI = function(title, message, timeout, onClose) {
  142. var $m = $('<div class="growlUI"></div>');
  143. if (title) $m.append('<h1>'+title+'</h1>');
  144. if (message) $m.append('<h2>'+message+'</h2>');
  145. if (timeout === undefined) timeout = 3000;
  146. // Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
  147. var callBlock = function(opts) {
  148. opts = opts || {};
  149. $.blockUI({
  150. message: $m,
  151. fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
  152. fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
  153. timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
  154. centerY: false,
  155. showOverlay: false,
  156. onUnblock: onClose,
  157. css: $.blockUI.defaults.growlCSS
  158. });
  159. };
  160. callBlock();
  161. var nonmousedOpacity = $m.css('opacity');
  162. $m.mouseover(function() {
  163. callBlock({
  164. fadeIn: 0,
  165. timeout: 30000
  166. });
  167. var displayBlock = $('.blockMsg');
  168. displayBlock.stop(); // cancel fadeout if it has started
  169. displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency
  170. }).mouseout(function() {
  171. $('.blockMsg').fadeOut(1000);
  172. });
  173. // End konapun additions
  174. };
  175. // plugin method for blocking element content
  176. $.fn.block = function(opts) {
  177. if ( this[0] === window ) {
  178. $.blockUI( opts );
  179. return this;
  180. }
  181. var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
  182. this.each(function() {
  183. var $el = $(this);
  184. if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
  185. return;
  186. $el.unblock({ fadeOut: 0 });
  187. });
  188. return this.each(function() {
  189. if ($.css(this,'position') == 'static') {
  190. this.style.position = 'relative';
  191. $(this).data('blockUI.static', true);
  192. }
  193. this.style.zoom = 1; // force 'hasLayout' in ie
  194. install(this, opts);
  195. });
  196. };
  197. // plugin method for unblocking element content
  198. $.fn.unblock = function(opts) {
  199. if ( this[0] === window ) {
  200. $.unblockUI( opts );
  201. return this;
  202. }
  203. return this.each(function() {
  204. remove(this, opts);
  205. });
  206. };
  207. $.blockUI.version = 2.66; // 2nd generation blocking at no extra cost!
  208. // override these in your code to change the default behavior and style
  209. $.blockUI.defaults = {
  210. // message displayed when blocking (use null for no message)
  211. message: '<h1>Please wait...</h1>',
  212. title: null, // title string; only used when theme == true
  213. draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
  214. theme: false, // set to true to use with jQuery UI themes
  215. // styles for the message when blocking; if you wish to disable
  216. // these and use an external stylesheet then do this in your code:
  217. // $.blockUI.defaults.css = {};
  218. css: {
  219. padding: 0,
  220. margin: 0,
  221. width: '30%',
  222. top: '40%',
  223. left: '35%',
  224. textAlign: 'center',
  225. color: '#fff',
  226. border: '3px solid #aaa',
  227. backgroundColor:'#000',
  228. cursor: 'wait'
  229. },
  230. // minimal style set used when themes are used
  231. themedCSS: {
  232. width: '30%',
  233. top: '40%',
  234. left: '35%'
  235. },
  236. // styles for the overlay
  237. overlayCSS: {
  238. backgroundColor: '#000',
  239. opacity: 0.6,
  240. cursor: 'wait'
  241. },
  242. // style to replace wait cursor before unblocking to correct issue
  243. // of lingering wait cursor
  244. cursorReset: 'default',
  245. // styles applied when using $.growlUI
  246. growlCSS: {
  247. width: '350px',
  248. top: '10px',
  249. left: '',
  250. right: '10px',
  251. border: 'none',
  252. padding: '5px',
  253. opacity: 0.6,
  254. cursor: 'default',
  255. color: '#fff',
  256. backgroundColor: '#000',
  257. '-webkit-border-radius':'10px',
  258. '-moz-border-radius': '10px',
  259. 'border-radius': '10px'
  260. },
  261. // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
  262. // (hat tip to Jorge H. N. de Vasconcelos)
  263. /*jshint scripturl:true */
  264. iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
  265. // force usage of iframe in non-IE browsers (handy for blocking applets)
  266. forceIframe: false,
  267. // z-index for the blocking overlay
  268. baseZ: 1000,
  269. // set these to true to have the message automatically centered
  270. centerX: true, // <-- only effects element blocking (page block controlled via css above)
  271. centerY: true,
  272. // allow body element to be stetched in ie6; this makes blocking look better
  273. // on "short" pages. disable if you wish to prevent changes to the body height
  274. allowBodyStretch: true,
  275. // enable if you want key and mouse events to be disabled for content that is blocked
  276. bindEvents: true,
  277. // be default blockUI will supress tab navigation from leaving blocking content
  278. // (if bindEvents is true)
  279. constrainTabKey: true,
  280. // fadeIn time in millis; set to 0 to disable fadeIn on block
  281. fadeIn: 200,
  282. // fadeOut time in millis; set to 0 to disable fadeOut on unblock
  283. fadeOut: 400,
  284. // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
  285. timeout: 0,
  286. // disable if you don't want to show the overlay
  287. showOverlay: true,
  288. // if true, focus will be placed in the first available input field when
  289. // page blocking
  290. focusInput: true,
  291. // elements that can receive focus
  292. focusableElements: ':input:enabled:visible',
  293. // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
  294. // no longer needed in 2012
  295. // applyPlatformOpacityRules: true,
  296. // callback method invoked when fadeIn has completed and blocking message is visible
  297. onBlock: null,
  298. // callback method invoked when unblocking has completed; the callback is
  299. // passed the element that has been unblocked (which is the window object for page
  300. // blocks) and the options that were passed to the unblock call:
  301. // onUnblock(element, options)
  302. onUnblock: null,
  303. // callback method invoked when the overlay area is clicked.
  304. // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
  305. onOverlayClick: null,
  306. // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
  307. quirksmodeOffsetHack: 4,
  308. // class name of the message block
  309. blockMsgClass: 'blockMsg',
  310. // if it is already blocked, then ignore it (don't unblock and reblock)
  311. ignoreIfBlocked: false
  312. };
  313. // private data and functions follow...
  314. var pageBlock = null;
  315. var pageBlockEls = [];
  316. function install(el, opts) {
  317. var css, themedCSS;
  318. var full = (el == window);
  319. var msg = (opts && opts.message !== undefined ? opts.message : undefined);
  320. opts = $.extend({}, $.blockUI.defaults, opts || {});
  321. if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
  322. return;
  323. opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
  324. css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
  325. if (opts.onOverlayClick)
  326. opts.overlayCSS.cursor = 'pointer';
  327. themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
  328. msg = msg === undefined ? opts.message : msg;
  329. // remove the current block (if there is one)
  330. if (full && pageBlock)
  331. remove(window, {fadeOut:0});
  332. // if an existing element is being used as the blocking content then we capture
  333. // its current place in the DOM (and current display style) so we can restore
  334. // it when we unblock
  335. if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
  336. var node = msg.jquery ? msg[0] : msg;
  337. var data = {};
  338. $(el).data('blockUI.history', data);
  339. data.el = node;
  340. data.parent = node.parentNode;
  341. data.display = node.style.display;
  342. data.position = node.style.position;
  343. if (data.parent)
  344. data.parent.removeChild(node);
  345. }
  346. $(el).data('blockUI.onUnblock', opts.onUnblock);
  347. var z = opts.baseZ;
  348. // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
  349. // layer1 is the iframe layer which is used to supress bleed through of underlying content
  350. // layer2 is the overlay layer which has opacity and a wait cursor (by default)
  351. // layer3 is the message content that is displayed while blocking
  352. var lyr1, lyr2, lyr3, s;
  353. if (msie || opts.forceIframe)
  354. lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
  355. else
  356. lyr1 = $('<div class="blockUI" style="display:none"></div>');
  357. if (opts.theme)
  358. lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
  359. else
  360. lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
  361. if (opts.theme && full) {
  362. s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
  363. if ( opts.title ) {
  364. s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
  365. }
  366. s += '<div class="ui-widget-content ui-dialog-content"></div>';
  367. s += '</div>';
  368. }
  369. else if (opts.theme) {
  370. s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
  371. if ( opts.title ) {
  372. s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
  373. }
  374. s += '<div class="ui-widget-content ui-dialog-content"></div>';
  375. s += '</div>';
  376. }
  377. else if (full) {
  378. s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
  379. }
  380. else {
  381. s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
  382. }
  383. lyr3 = $(s);
  384. // if we have a message, style it
  385. if (msg) {
  386. if (opts.theme) {
  387. lyr3.css(themedCSS);
  388. lyr3.addClass('ui-widget-content');
  389. }
  390. else
  391. lyr3.css(css);
  392. }
  393. // style the overlay
  394. if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
  395. lyr2.css(opts.overlayCSS);
  396. lyr2.css('position', full ? 'fixed' : 'absolute');
  397. // make iframe layer transparent in IE
  398. if (msie || opts.forceIframe)
  399. lyr1.css('opacity',0.0);
  400. //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
  401. var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
  402. $.each(layers, function() {
  403. this.appendTo($par);
  404. });
  405. if (opts.theme && opts.draggable && $.fn.draggable) {
  406. lyr3.draggable({
  407. handle: '.ui-dialog-titlebar',
  408. cancel: 'li'
  409. });
  410. }
  411. // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
  412. var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
  413. if (ie6 || expr) {
  414. // give body 100% height
  415. if (full && opts.allowBodyStretch && $.support.boxModel)
  416. $('html,body').css('height','100%');
  417. // fix ie6 issue when blocked element has a border width
  418. if ((ie6 || !$.support.boxModel) && !full) {
  419. var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
  420. var fixT = t ? '(0 - '+t+')' : 0;
  421. var fixL = l ? '(0 - '+l+')' : 0;
  422. }
  423. // simulate fixed position
  424. $.each(layers, function(i,o) {
  425. var s = o[0].style;
  426. s.position = 'absolute';
  427. if (i < 2) {
  428. if (full)
  429. s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
  430. else
  431. s.setExpression('height','this.parentNode.offsetHeight + "px"');
  432. if (full)
  433. s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
  434. else
  435. s.setExpression('width','this.parentNode.offsetWidth + "px"');
  436. if (fixL) s.setExpression('left', fixL);
  437. if (fixT) s.setExpression('top', fixT);
  438. }
  439. else if (opts.centerY) {
  440. if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
  441. s.marginTop = 0;
  442. }
  443. else if (!opts.centerY && full) {
  444. var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
  445. var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
  446. s.setExpression('top',expression);
  447. }
  448. });
  449. }
  450. // show the message
  451. if (msg) {
  452. if (opts.theme)
  453. lyr3.find('.ui-widget-content').append(msg);
  454. else
  455. lyr3.append(msg);
  456. if (msg.jquery || msg.nodeType)
  457. $(msg).show();
  458. }
  459. if ((msie || opts.forceIframe) && opts.showOverlay)
  460. lyr1.show(); // opacity is zero
  461. if (opts.fadeIn) {
  462. var cb = opts.onBlock ? opts.onBlock : noOp;
  463. var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
  464. var cb2 = msg ? cb : noOp;
  465. if (opts.showOverlay)
  466. lyr2._fadeIn(opts.fadeIn, cb1);
  467. if (msg)
  468. lyr3._fadeIn(opts.fadeIn, cb2);
  469. }
  470. else {
  471. if (opts.showOverlay)
  472. lyr2.show();
  473. if (msg)
  474. lyr3.show();
  475. if (opts.onBlock)
  476. opts.onBlock();
  477. }
  478. // bind key and mouse events
  479. bind(1, el, opts);
  480. if (full) {
  481. pageBlock = lyr3[0];
  482. pageBlockEls = $(opts.focusableElements,pageBlock);
  483. if (opts.focusInput)
  484. setTimeout(focus, 20);
  485. }
  486. else
  487. center(lyr3[0], opts.centerX, opts.centerY);
  488. if (opts.timeout) {
  489. // auto-unblock
  490. var to = setTimeout(function() {
  491. if (full)
  492. $.unblockUI(opts);
  493. else
  494. $(el).unblock(opts);
  495. }, opts.timeout);
  496. $(el).data('blockUI.timeout', to);
  497. }
  498. }
  499. // remove the block
  500. function remove(el, opts) {
  501. var count;
  502. var full = (el == window);
  503. var $el = $(el);
  504. var data = $el.data('blockUI.history');
  505. var to = $el.data('blockUI.timeout');
  506. if (to) {
  507. clearTimeout(to);
  508. $el.removeData('blockUI.timeout');
  509. }
  510. opts = $.extend({}, $.blockUI.defaults, opts || {});
  511. bind(0, el, opts); // unbind events
  512. if (opts.onUnblock === null) {
  513. opts.onUnblock = $el.data('blockUI.onUnblock');
  514. $el.removeData('blockUI.onUnblock');
  515. }
  516. var els;
  517. if (full) // crazy selector to handle odd field errors in ie6/7
  518. els = $('body').children().filter('.blockUI').add('body > .blockUI');
  519. else
  520. els = $el.find('>.blockUI');
  521. // fix cursor issue
  522. if ( opts.cursorReset ) {
  523. if ( els.length > 1 )
  524. els[1].style.cursor = opts.cursorReset;
  525. if ( els.length > 2 )
  526. els[2].style.cursor = opts.cursorReset;
  527. }
  528. if (full)
  529. pageBlock = pageBlockEls = null;
  530. if (opts.fadeOut) {
  531. count = els.length;
  532. els.stop().fadeOut(opts.fadeOut, function() {
  533. if ( --count === 0)
  534. reset(els,data,opts,el);
  535. });
  536. }
  537. else
  538. reset(els, data, opts, el);
  539. }
  540. // move blocking element back into the DOM where it started
  541. function reset(els,data,opts,el) {
  542. var $el = $(el);
  543. if ( $el.data('blockUI.isBlocked') )
  544. return;
  545. els.each(function(i,o) {
  546. // remove via DOM calls so we don't lose event handlers
  547. if (this.parentNode)
  548. this.parentNode.removeChild(this);
  549. });
  550. if (data && data.el) {
  551. data.el.style.display = data.display;
  552. data.el.style.position = data.position;
  553. if (data.parent)
  554. data.parent.appendChild(data.el);
  555. $el.removeData('blockUI.history');
  556. }
  557. if ($el.data('blockUI.static')) {
  558. $el.css('position', 'static'); // #22
  559. }
  560. if (typeof opts.onUnblock == 'function')
  561. opts.onUnblock(el,opts);
  562. // fix issue in Safari 6 where block artifacts remain until reflow
  563. var body = $(document.body), w = body.width(), cssW = body[0].style.width;
  564. body.width(w-1).width(w);
  565. body[0].style.width = cssW;
  566. }
  567. // bind/unbind the handler
  568. function bind(b, el, opts) {
  569. var full = el == window, $el = $(el);
  570. // don't bother unbinding if there is nothing to unbind
  571. if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
  572. return;
  573. $el.data('blockUI.isBlocked', b);
  574. // don't bind events when overlay is not in use or if bindEvents is false
  575. if (!full || !opts.bindEvents || (b && !opts.showOverlay))
  576. return;
  577. // bind anchors and inputs for mouse and key events
  578. var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
  579. if (b)
  580. $(document).bind(events, opts, handler);
  581. else
  582. $(document).unbind(events, handler);
  583. // former impl...
  584. // var $e = $('a,:input');
  585. // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
  586. }
  587. // event handler to suppress keyboard/mouse events when blocking
  588. function handler(e) {
  589. // allow tab navigation (conditionally)
  590. if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
  591. if (pageBlock && e.data.constrainTabKey) {
  592. var els = pageBlockEls;
  593. var fwd = !e.shiftKey && e.target === els[els.length-1];
  594. var back = e.shiftKey && e.target === els[0];
  595. if (fwd || back) {
  596. setTimeout(function(){focus(back);},10);
  597. return false;
  598. }
  599. }
  600. }
  601. var opts = e.data;
  602. var target = $(e.target);
  603. if (target.hasClass('blockOverlay') && opts.onOverlayClick)
  604. opts.onOverlayClick(e);
  605. // allow events within the message content
  606. if (target.parents('div.' + opts.blockMsgClass).length > 0)
  607. return true;
  608. // allow events for content that is not being blocked
  609. return target.parents().children().filter('div.blockUI').length === 0;
  610. }
  611. function focus(back) {
  612. if (!pageBlockEls)
  613. return;
  614. var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
  615. if (e)
  616. e.focus();
  617. }
  618. function center(el, x, y) {
  619. var p = el.parentNode, s = el.style;
  620. var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
  621. var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
  622. if (x) s.left = l > 0 ? (l+'px') : '0';
  623. if (y) s.top = t > 0 ? (t+'px') : '0';
  624. }
  625. function sz(el, p) {
  626. return parseInt($.css(el,p),10)||0;
  627. }
  628. }
  629. /*global define:true */
  630. if (typeof define === 'function' && define.amd && define.amd.jQuery) {
  631. define(['jquery'], setup);
  632. } else {
  633. setup(jQuery);
  634. }
  635. })();
  636. /**
  637. * Minimal utility for dispatching signals (events).
  638. */
  639. kontext.Signal = function() {
  640. this.listeners = [];
  641. }
  642. kontext.Signal.prototype.add = function( callback ) {
  643. this.listeners.push( callback );
  644. }
  645. kontext.Signal.prototype.remove = function( callback ) {
  646. var i = this.listeners.indexOf( callback );
  647. if( i >= 0 ) this.listeners.splice( i, 1 );
  648. }
  649. kontext.Signal.prototype.dispatch = function() {
  650. var args = Array.prototype.slice.call( arguments );
  651. this.listeners.forEach( function( f, i ) {
  652. f.apply( null, args );
  653. } );
  654. }
  655. // Event scroll
  656. $(document).scroll(function(){
  657. var docViewTop = $(window).scrollTop();
  658. //var docViewBottom = docViewTop + $(window).height();
  659. if($(".main-header-menu").length > 0){
  660. var elemTop = $(".main-header-menu").offset().top;
  661. //var elemBottom = elemTop + $(".blog-menu").height();
  662. if(docViewTop > elemTop){
  663. $(".main-header-search").addClass('menu-active');
  664. //$(".main-header-search").addClass('main-header-search-fixed');
  665. $('.notification').css('display','none');
  666. $('.close-notification').css('display','none');
  667. }else{
  668. $(".main-header-search").removeClass('menu-active');
  669. //$(".main-header-search").removeClass('main-header-search-fixed');
  670. $('.notification').css('display','block');
  671. $('.close-notification').css('display','block');
  672. }
  673. }
  674. });
  675. $(document).ready(function(){
  676. //open avatar menu
  677. $checkAvatarMenu = 1;
  678. $('.avatar-menu-item').on('click', function (event) {
  679. console.log(11111);
  680. if($checkAvatarMenu == 1){
  681. $(this).toggleClass('open');
  682. }
  683. });
  684. $('.avatar-drop-menu').click(function(){
  685. $checkAvatarMenu = 0;
  686. setTimeout(function(){
  687. $checkAvatarMenu = 1;
  688. },200)
  689. });
  690. $('body').on('click', function (e) {
  691. if (!$('.avatar-menu-item').is(e.target)
  692. && $('.avatar-menu-item').has(e.target).length === 0
  693. && $('.open').has(e.target).length === 0
  694. ){
  695. $('.avatar-menu-item').removeClass('open');
  696. }
  697. });
  698. });
  699. $(document).ready(function(){
  700. $(document).on("change","input[name='loginRememberPassword']",function(){
  701. if($(this).prop("checked") == true){
  702. $(this).parent().css("color", "#4c87ed");
  703. }else{
  704. $(this).parent().css("color", "#4b4b4b");
  705. }
  706. })
  707. //Effect for login input
  708. $(document).on('shown.bs.modal','#loginModal', function () {
  709. $("input[name='loginEmail']").focus()
  710. });
  711. //Effect for login input
  712. $(document).on('click','.loginNameInputText',function(){
  713. $(this).prev().focus();
  714. });
  715. //Effect for login input
  716. $(document).on('focusin',".loginInputText",function(){
  717. if(!$(this).next().hasClass('loginFocusInput')){
  718. $(this).next().addClass('loginFocusInput');
  719. }
  720. });
  721. //Effect for login input loginHasText
  722. $(document).on('focusout',".loginInputText", outInput);
  723. $(".loginInputText").focusout(outInput);
  724. var checkOutInput = 1;
  725. function outInput(){
  726. if(checkOutInput == 1){
  727. if($(this).next().hasClass('loginFocusInput')){
  728. $(this).next().removeClass('loginFocusInput');
  729. }
  730. if($(this).next().hasClass('loginHasText') && $(this).val() == ''){
  731. $(this).next().removeClass('loginHasText');
  732. }
  733. if(!$(this).next().hasClass('loginHasText') && $(this).val() != ''){
  734. $(this).next().addClass('loginHasText');
  735. }
  736. checkOutInput = 0;
  737. setTimeout(function() {
  738. checkOutInput = 1;
  739. }, 50);
  740. }
  741. }
  742. //Effect for login button
  743. $(document).on("keyup","input[name='loginEmail'], input[name='loginPassword']", function(){
  744. if(checkRegisterEmail($("input[name='loginEmail']").val())
  745. && $("input[name='loginPassword']").val() != ''){
  746. $(".loginButtonSubmit").addClass("loginSuccess");
  747. }else{
  748. $(".loginButtonSubmit").removeClass("loginSuccess");
  749. }
  750. });
  751. $(document).on('keypress',"input[name='loginEmail'], input[name='loginPassword']" ,function(e){
  752. if(e.keyCode == 13){
  753. $( ".loginButtonSubmit" ).trigger( "click" );
  754. }
  755. });
  756. //Effect for register input
  757. $(document).on("keyup","input[name='registerName']",function(){
  758. if(checkRegisterName($(this).val())){
  759. $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
  760. }else{
  761. $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
  762. }
  763. });
  764. $(document).on("keyup","input[name='registerEmail']",function(){
  765. if(checkRegisterEmail($(this).val())){
  766. $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
  767. }else{
  768. $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
  769. }
  770. });
  771. $(document).on("keyup","input[name='registerPassword']",function(){
  772. if(checkRegisterPassword($(this).val())){
  773. $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
  774. }else{
  775. $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
  776. }
  777. });
  778. //Effect for register button
  779. $(document).on("keyup change","input[name='registerName'], input[name='registerEmail'], input[name='registerPassword'], input[name='registerCaptcha'], input[name='registerAgreeVocaRule']", function(){
  780. if(checkRegisterName($("input[name='registerName']").val())
  781. && checkRegisterEmail($("input[name='registerEmail']").val())
  782. && checkRegisterPassword($("input[name='registerPassword']").val())
  783. && $("input[name='registerAgreeVocaRule']").prop("checked")){
  784. $(".registerButtonSubmit").addClass("registerSuccess");
  785. }else{
  786. $(".registerButtonSubmit").removeClass("registerSuccess");
  787. }
  788. });
  789. $(document).on('keyup',"#loginModal input, #registerModal input, #forgotPasswordModal input, #activeCodeModal input", function(){
  790. $(this).parent().find(".loginErrorInput").css("display", "none");
  791. });
  792. $(document).on('keyup',"input[name='registerCaptcha']", function(){
  793. $(".registerCaptchaIncorrect").css('display', 'none');
  794. $(".registerDontEnterCaptcha").css('display', 'none');
  795. });
  796. //Effect for login input
  797. $(document).on('shown.bs.modal','#registerModal', function () {
  798. $("input[name='registerName']").focus();
  799. $('#registerModal .registerResetCaptcha').click();
  800. });
  801. $(document).on("click",".loginDontAccount",function(){
  802. $('#registerModal').modal('show');
  803. setTimeout(function(){
  804. $("body").addClass("modal-open");
  805. },500);
  806. });
  807. $(document).on("click",".loginForgotPassword",function(){
  808. $('#forgotPasswordModal').modal('show');
  809. setTimeout(function(){
  810. $("body").addClass("modal-open");
  811. },500);
  812. });
  813. $(document).on('keypress',"input[name='registerName'], input[name='registerEmail'], input[name='registerPassword'], input[name='registerCaptcha']" ,function(e){
  814. if(e.keyCode == 13){
  815. $( ".registerButtonSubmit" ).trigger( "click" );
  816. }
  817. });
  818. $(document).on("focusout","input[name='loginEmail']",function(){
  819. var email = $("input[name='loginEmail']").val();
  820. if(email == ''){
  821. $(".dontEnterEmail").css('display', 'block');
  822. return false;
  823. }else{
  824. $(".dontEnterEmail").css('display', 'none');
  825. }
  826. if(!checkRegisterEmail(email)){
  827. $(".loginEmailInvalid").css('display', 'block');
  828. return false;
  829. }else{
  830. $(".loginEmailInvalid").css('display', 'none');
  831. }
  832. });
  833. $(document).on("focusout","input[name='loginPassword']",function(){
  834. var password = $("input[name='loginPassword']").val();
  835. if(password == ''){
  836. $(".dontEnterPassword").css('display', 'block');
  837. return false;
  838. }else{
  839. $(".dontEnterPassword").css('display', 'none');
  840. }
  841. });
  842. $(document).on("focusout","input[name='registerName']",function(){
  843. var name = $("input[name='registerName']").val();
  844. if(name == ''){
  845. $(".registerDontEnterName").css('display', 'block');
  846. return false;
  847. }else{
  848. $(".registerDontEnterName").css('display', 'none');
  849. }
  850. if(name.length < 5){
  851. $(".registerNameShort").css('display', 'block');
  852. return false;
  853. }else{
  854. $(".registerNameShort").css('display', 'none');
  855. }
  856. if(name.length >= 255){
  857. $(".registerNameLong").css('display', 'block');
  858. return false;
  859. }else{
  860. $(".registerNameLong").css('display', 'none');
  861. }
  862. });
  863. $(document).on("focusout","input[name='registerEmail']",function(){
  864. var email = $("input[name='registerEmail']").val();
  865. if(email == ''){
  866. $(".registerDontEnterEmail").css('display', 'block');
  867. return false;
  868. }else{
  869. $(".registerDontEnterEmail").css('display', 'none');
  870. }
  871. if(!checkRegisterEmail(email)){
  872. $(".registerEmailInvalid").css('display', 'block');
  873. return false;
  874. }else{
  875. $(".registerEmailInvalid").css('display', 'none');
  876. }
  877. });
  878. $(document).on("focusout","input[name='registerPassword']",function(){
  879. var password = $("input[name='registerPassword']").val();
  880. if(password == ''){
  881. $(".registerDontEnterPassword").css('display', 'block');
  882. return false;
  883. }else{
  884. $(".registerDontEnterPassword").css('display', 'none');
  885. }
  886. if(password.length < 5){
  887. $(".registerPasswordShort").css('display', 'block');
  888. return false;
  889. }else{
  890. $(".registerPasswordShort").css('display', 'none');
  891. }
  892. if(password.length >= 255){
  893. $(".registerPasswordLong").css('display', 'block');
  894. return false;
  895. }else{
  896. $(".registerPasswordLong").css('display', 'none');
  897. }
  898. });
  899. $(document).on("focusout","input[name='registerCaptcha']",function(){
  900. var captcha = $("input[name='registerCaptcha']").val();
  901. if(captcha == ''){
  902. $(".registerDontEnterCaptcha").css('display', 'block');
  903. return false;
  904. }else{
  905. $(".registerDontEnterCaptcha").css('display', 'none');
  906. }
  907. });
  908. //Effect for login button
  909. $(document).on("keyup","input[name='forgotPasswordEmail'], input[name='forgotPasswordCaptcha']", function(){
  910. if(checkRegisterEmail($("input[name='forgotPasswordEmail']").val())){
  911. $(".forgotPasswordButtonSubmit").addClass("forgotPasswordSuccess");
  912. }else{
  913. $(".forgotPasswordButtonSubmit").removeClass("forgotPasswordSuccess");
  914. }
  915. });
  916. //Effect for login button
  917. $(document).on("keyup","input[name='activeCodeEmail'], input[name='activeCodeCaptcha']", function(){
  918. if(checkRegisterEmail($("input[name='activeCodeEmail']").val())){
  919. $(".activeCodeButtonSubmit").addClass("activeCodeSuccess");
  920. }else{
  921. $(".activeCodeButtonSubmit").removeClass("activeCodeSuccess");
  922. }
  923. });
  924. $(document).on('keypress',"input[name='forgotPasswordEmail'], input[name='forgotPasswordCaptcha']" ,function(e){
  925. if(e.keyCode == 13){
  926. $( ".forgotPasswordButtonSubmit" ).trigger( "click" );
  927. }
  928. });
  929. $(document).on('keypress',"input[name='activeCodeEmail'], input[name='activeCodeCaptcha']" ,function(e){
  930. if(e.keyCode == 13){
  931. $( ".activeCodeButtonSubmit" ).trigger( "click" );
  932. }
  933. });
  934. $(document).on("focusout","input[name='forgotPasswordEmail']",function(){
  935. var email = $("input[name='forgotPasswordEmail']").val();
  936. if(email == ''){
  937. $(".forgotPasswordDontEnterEmail").css('display', 'block');
  938. return false;
  939. }else{
  940. $(".forgotPasswordDontEnterEmail").css('display', 'none');
  941. }
  942. if(!checkRegisterEmail(email)){
  943. $(".forgotPasswordEmailInvalid").css('display', 'block');
  944. return false;
  945. }else{
  946. $(".forgotPasswordEmailInvalid").css('display', 'none');
  947. }
  948. });
  949. $(document).on("focusout","input[name='activeCodeEmail']",function(){
  950. var email = $("input[name='activeCodeEmail']").val();
  951. if(email == ''){
  952. $(".activeCodeDontEnterEmail").css('display', 'block');
  953. return false;
  954. }else{
  955. $(".activeCodeDontEnterEmail").css('display', 'none');
  956. }
  957. if(!checkRegisterEmail(email)){
  958. $(".activeCodeEmailInvalid").css('display', 'block');
  959. return false;
  960. }else{
  961. $(".activeCodeEmailInvalid").css('display', 'none');
  962. }
  963. });
  964. $(document).on("focusout","input[name='forgotPasswordCaptcha']",function(){
  965. var captcha = $("input[name='forgotPasswordCaptcha']").val();
  966. if(captcha == ''){
  967. $(".forgotPasswordDontEnterCaptcha").css('display', 'block');
  968. return false;
  969. }else{
  970. $(".forgotPasswordDontEnterCaptcha").css('display', 'none');
  971. }
  972. });
  973. $(document).on("focusout","input[name='activeCodeCaptcha']",function(){
  974. var captcha = $("input[name='activeCodeCaptcha']").val();
  975. if(captcha == ''){
  976. $(".activeCodeDontEnterCaptcha").css('display', 'block');
  977. return false;
  978. }else{
  979. $(".activeCodeDontEnterCaptcha").css('display', 'none');
  980. }
  981. });
  982. $(document).on('shown.bs.modal','#forgotPasswordModal', function () {
  983. $('#forgotPasswordModal .registerResetCaptcha').click();
  984. });
  985. $(document).on('shown.bs.modal','#activeCodeModal', function () {
  986. $('#activeCodeModal .registerResetCaptcha').click();
  987. });
  988. $(document).on("click",".forgotPasswordEnterAgain",function(){
  989. $("#forgotPasswordErrorModal").modal('hide');
  990. $("#forgotPasswordModal").modal('show');
  991. setTimeout(function(){
  992. $("body").addClass("modal-open");
  993. },500);
  994. });
  995. $(document).on("click",".activeCodeEnterAgain",function(){
  996. $("#activeCodeErrorModal").modal('hide');
  997. $("#activeCodeModal").modal('show');
  998. setTimeout(function(){
  999. $("body").addClass("modal-open");
  1000. },500);
  1001. });
  1002. $(document).on('click','.btn-active-code.activeCodeSuccess',function(){
  1003. var email = $('.txt-email-reset').val();
  1004. var token = $('input[name="active_code_token"]').val();
  1005. $('.reset-password-msg').html('');
  1006. $('.reset-password-msg').removeClass('reset-password-msg-success');
  1007. $.ajax({
  1008. url : urlConfig('auth/get-back-activate'),
  1009. data : {
  1010. email : email,
  1011. active_code_token: token,
  1012. is_modal : 1
  1013. },
  1014. headers: {
  1015. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  1016. },
  1017. type: 'POST'
  1018. }).success(function(data){
  1019. if(data.email){
  1020. $('.reset-password-msg').html(data.email.toString());
  1021. return false;
  1022. }else{
  1023. $('.reset-password-msg').html('');
  1024. }
  1025. if(!data.email ){
  1026. $('.reset-password-msg').addClass('reset-password-msg-success');
  1027. $('.txt-email-reset').val('');
  1028. $('.reset-password-msg').html(data);
  1029. }
  1030. });
  1031. });
  1032. $(document).on('click','.loginForgotPassword.forgot-password a',function(){
  1033. $.ajax({
  1034. url : urlConfig('auth/get-password'),
  1035. type: 'GET'
  1036. }).success(function(data){
  1037. $('#modal-reset-password').html(data);
  1038. $('#modal-reset-password').modal();
  1039. });
  1040. });
  1041. $(document).on('click','.btn-reset-password.forgotPasswordSuccess',function(){
  1042. var email = $('.txt-email-reset-password').val();
  1043. var token = $('input[name="reset_password_token"]').val();
  1044. $('.reset-password-msg').html('');
  1045. $('.reset-password-msg').removeClass('reset-password-msg-success');
  1046. $.ajax({
  1047. url : urlConfig('auth/get-password'),
  1048. data : {
  1049. email : email,
  1050. reset_password_token: token
  1051. },
  1052. headers: {
  1053. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  1054. },
  1055. type: 'POST'
  1056. }).success(function(data){
  1057. if(data.email){
  1058. $('.reset-password-msg').html(data.email.toString());
  1059. return false;
  1060. }else{
  1061. $('.reset-password-msg').html('');
  1062. }
  1063. if(!data.email ){
  1064. $('.reset-password-msg').addClass('reset-password-msg-success');
  1065. $('.txt-email-reset-password').val('');
  1066. $('.reset-password-msg').html(data);
  1067. }
  1068. });
  1069. });
  1070. $(document).on('keypress','#sign-in-email, #sign-in-password',function(e){
  1071. if(e.keyCode == 13){
  1072. $( ".modal-sign-in-button-create" ).trigger( "click" );
  1073. }
  1074. });
  1075. $(document).on('click','.modal-sign-in-button-create.button-active',function(){
  1076. var email = $('#sign-in-email').val();
  1077. var password = $('#sign-in-password').val();
  1078. var curUrl = $('#current-url').val();
  1079. if(curUrl == undefined){
  1080. curUrl = "";
  1081. }
  1082. $('[data-toggle="tooltip"]').tooltip('hide');
  1083. $.ajax({
  1084. url : urlConfig('auth/signin'),
  1085. data : {
  1086. email : email,
  1087. password : password,
  1088. rememberPass : 1,
  1089. curUrl: curUrl
  1090. },
  1091. headers: {
  1092. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  1093. },
  1094. type: 'POST'
  1095. }).success(function(data){
  1096. if(data.length > 2000){
  1097. $('body').append(data);
  1098. $('#modal-login-system').modal('hide');
  1099. $('#register-msg-modal').modal();
  1100. }else{
  1101. if(data.email){
  1102. $('#sign-in-email').attr('title', data.email.toString());
  1103. $('#sign-in-email').attr('data-original-title', data.email.toString());
  1104. $('#sign-in-email').tooltip('show');
  1105. $('[data-toggle="tooltip"]').tooltip();
  1106. }
  1107. if(data.password){
  1108. $('#sign-in-password').attr('title', data.password.toString());
  1109. $('#sign-in-password').attr('data-original-title', data.password.toString());
  1110. $('#sign-in-password').tooltip('show');
  1111. $('[data-toggle="tooltip"]').tooltip();
  1112. }
  1113. if(!data.email && !data.password){
  1114. if(data[0] != "success"){
  1115. $('#sign-in-email').attr('title', data);
  1116. $('#sign-in-email').attr('data-original-title', data);
  1117. $('#sign-in-email').tooltip('show');
  1118. $('[data-toggle="tooltip"]').tooltip();
  1119. }else{
  1120. $('#modal-login-system').modal('hide');
  1121. if(data[1].indexOf("http") > -1){
  1122. window.location.href = data[1];
  1123. }else{
  1124. window.location.href = urlConfig(data[1]);
  1125. }
  1126. }
  1127. }
  1128. }
  1129. });
  1130. });
  1131. $(document).on('keypress','#sign-up-email, #sign-up-password, #sign-up-name',function(e){
  1132. if(e.keyCode == 13){
  1133. $( ".modal-sign-up-button-create" ).trigger( "click" );
  1134. }
  1135. });
  1136. //register system
  1137. $(document).on('click','.modal-sign-up-button-create.button-active',function(){
  1138. var registerToken = $('input[name="register_token"]').val();
  1139. var email = $('#sign-up-email').val();
  1140. var password = $('#sign-up-password').val();
  1141. var name = $('#sign-up-name').val();
  1142. var agree = 1;
  1143. var curUrl = $('#current-url').val();
  1144. if(curUrl == undefined){
  1145. curUrl = "";
  1146. }
  1147. $('[data-toggle="tooltip"]').tooltip('hide');
  1148. $.ajax({
  1149. url : urlConfig('auth/signup'),
  1150. data : {
  1151. email : email,
  1152. password : password,
  1153. full_name : name,
  1154. register_token: registerToken,
  1155. curUrl : curUrl
  1156. },
  1157. headers: {
  1158. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  1159. },
  1160. type: 'POST'
  1161. }).success(function(data){
  1162. $('#sign-up-password').val('');
  1163. if(data.email){
  1164. $('#sign-up-email').attr('title', data.email.toString());
  1165. $('#sign-up-email').attr('data-original-title', data.email.toString());
  1166. $('#sign-up-email').tooltip('show');
  1167. $('[data-toggle="tooltip"]').tooltip();
  1168. }
  1169. if(data.password){
  1170. $('#sign-up-password').attr('title', data.password.toString());
  1171. $('#sign-up-password').attr('data-original-title', data.password.toString());
  1172. $('#sign-up-password').tooltip('show');
  1173. $('[data-toggle="tooltip"]').tooltip();
  1174. }
  1175. if(!data.email && !data.password){
  1176. if(data[0] != "success"){
  1177. $('#sign-up-email').attr('title', data.toString());
  1178. $('#sign-up-email').attr('data-original-title', data.toString());
  1179. $('#sign-up-email').tooltip('show');
  1180. $('[data-toggle="tooltip"]').tooltip();
  1181. }else{
  1182. if(data[1] == ""){
  1183. window.location.href = urlConfig('my-library');
  1184. }else{
  1185. window.location.href = urlConfig(data[1]);
  1186. }
  1187. }
  1188. }
  1189. });
  1190. });
  1191. });
  1192. $(function () {
  1193. $('[data-toggle="tooltip"]').tooltip();
  1194. });
  1195. function checkRegisterName(name){
  1196. if(name.length >= 3 && name.length < 255){
  1197. return true;
  1198. }else{
  1199. return false;
  1200. }
  1201. }
  1202. function checkRegisterEmail(email){
  1203. var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  1204. return re.test(email);
  1205. }
  1206. function checkRegisterPassword(password){
  1207. if(password.length >= 5 && password.length < 255){
  1208. return true;
  1209. }else{
  1210. return false;
  1211. }
  1212. }
  1213. function isFunction(functionToCheck) {
  1214. return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
  1215. }
  1216. $(document).ready(function(){
  1217. /**begin menu tab mobile**/
  1218. $('.view-more-menu').click(function(){
  1219. $('.left-menu-mobile').animate({
  1220. 'left': 0
  1221. },function(){
  1222. $('body').addClass('left-menu-mobile-open');
  1223. $('.left-menu-mobile-ovelay').fadeIn();
  1224. });
  1225. });
  1226. $('.left-menu-mobile-ovelay').click(function(){
  1227. $('body').removeClass('left-menu-mobile-open');
  1228. $('.left-menu-mobile-ovelay').fadeOut();
  1229. $('.left-menu-mobile').animate({
  1230. 'left': '-250px'
  1231. },function(){
  1232. });
  1233. });
  1234. $('.left-menu-mobile-libray').click(function(){
  1235. $('.left-menu-mobile-libray-item').slideToggle();
  1236. });
  1237. /**end menu tab mobile**/
  1238. $('.main-header-menu .link.link-question-answer').mouseenter(function(){
  1239. $(this).find('ul').fadeIn();
  1240. });
  1241. $('.main-header-menu .link.link-question-answer').mouseleave(function(){
  1242. $(this).find('ul').fadeOut();
  1243. });
  1244. });