You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

923 lines
29 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. /*
  2. * # Semantic - Sidebar
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2014 Contributor
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. ;(function ( $, window, document, undefined ) {
  12. "use strict";
  13. $.fn.sidebar = function(parameters) {
  14. var
  15. $allModules = $(this),
  16. $head = $('head'),
  17. moduleSelector = $allModules.selector || '',
  18. time = new Date().getTime(),
  19. performance = [],
  20. query = arguments[0],
  21. methodInvoked = (typeof query == 'string'),
  22. queryArguments = [].slice.call(arguments, 1),
  23. requestAnimationFrame = window.requestAnimationFrame
  24. || window.mozRequestAnimationFrame
  25. || window.webkitRequestAnimationFrame
  26. || window.msRequestAnimationFrame
  27. || function(callback) { setTimeout(callback, 0); },
  28. returnedValue
  29. ;
  30. $allModules
  31. .each(function() {
  32. var
  33. settings = ( $.isPlainObject(parameters) )
  34. ? $.extend(true, {}, $.fn.sidebar.settings, parameters)
  35. : $.extend({}, $.fn.sidebar.settings),
  36. selector = settings.selector,
  37. className = settings.className,
  38. namespace = settings.namespace,
  39. error = settings.error,
  40. eventNamespace = '.' + namespace,
  41. moduleNamespace = 'module-' + namespace,
  42. $module = $(this),
  43. $context = $(settings.context),
  44. $sidebars = $module.children(selector.sidebar),
  45. $pusher = $context.children(selector.pusher),
  46. $style,
  47. element = this,
  48. instance = $module.data(moduleNamespace),
  49. currentScroll,
  50. transitionEvent,
  51. module
  52. ;
  53. module = {
  54. initialize: function() {
  55. module.debug('Initializing sidebar', parameters);
  56. transitionEvent = module.get.transitionEvent();
  57. // cache on initialize
  58. if( module.is.legacy() ) {
  59. settings.useLegacy = true;
  60. }
  61. // avoid locking rendering if included in onReady
  62. requestAnimationFrame(module.setup.layout);
  63. module.instantiate();
  64. },
  65. instantiate: function() {
  66. module.verbose('Storing instance of module', module);
  67. instance = module;
  68. $module
  69. .data(moduleNamespace, module)
  70. ;
  71. },
  72. destroy: function() {
  73. module.verbose('Destroying previous module for', $module);
  74. module.remove.direction();
  75. $module
  76. .off(eventNamespace)
  77. .removeData(moduleNamespace)
  78. ;
  79. },
  80. event: {
  81. clickaway: function(event) {
  82. if( $module.find(event.target).size() === 0 && $(event.target).filter($module).size() === 0 ) {
  83. module.verbose('User clicked on dimmed page');
  84. module.hide();
  85. }
  86. },
  87. touch: function(event) {
  88. //event.stopPropagation();
  89. },
  90. containScroll: function(event) {
  91. if(element.scrollTop <= 0) {
  92. element.scrollTop = 1;
  93. }
  94. if((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
  95. element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
  96. }
  97. },
  98. scroll: function(event) {
  99. if( $module.find(event.target).size() === 0 && $(event.target).filter($module).size() === 0 ) {
  100. event.preventDefault();
  101. }
  102. }
  103. },
  104. bind: {
  105. clickaway: function() {
  106. if(settings.scrollLock) {
  107. $(window)
  108. .on('DOMMouseScroll' + eventNamespace, module.event.scroll)
  109. ;
  110. }
  111. $(document)
  112. .on('touchmove' + eventNamespace, module.event.touch)
  113. ;
  114. $module
  115. .on('scroll' + eventNamespace, module.event.containScroll)
  116. ;
  117. if(settings.closable) {
  118. $context
  119. .on('click' + eventNamespace, module.event.clickaway)
  120. .on('touchend' + eventNamespace, module.event.clickaway)
  121. ;
  122. }
  123. }
  124. },
  125. unbind: {
  126. clickaway: function() {
  127. $context.off(eventNamespace);
  128. $pusher.off(eventNamespace);
  129. $(document).off(eventNamespace);
  130. $(window).off(eventNamespace);
  131. }
  132. },
  133. add: {
  134. bodyCSS: function(direction, distance) {
  135. var
  136. width = $module.outerWidth(),
  137. height = $module.outerHeight(),
  138. style = ''
  139. + '<style title="' + namespace + '">'
  140. + ' .ui.visible.left.sidebar ~ .fixed,'
  141. + ' .ui.visible.left.sidebar ~ .pusher {'
  142. + ' -webkit-transform: translate3d('+ width + 'px, 0, 0);'
  143. + ' transform: translate3d('+ width + 'px, 0, 0);'
  144. + ' }'
  145. + ' .ui.visible.right.sidebar ~ .fixed,'
  146. + ' .ui.visible.right.sidebar ~ .pusher {'
  147. + ' -webkit-transform: translate3d(-'+ width + 'px, 0, 0);'
  148. + ' transform: translate3d(-'+ width + 'px, 0, 0);'
  149. + ' }'
  150. + ' .ui.visible.top.sidebar ~ .fixed,'
  151. + ' .ui.visible.top.sidebar ~ .pusher {'
  152. + ' -webkit-transform: translate3d(0, ' + height + 'px, 0);'
  153. + ' transform: translate3d(0, ' + height + 'px, 0);'
  154. + ' }'
  155. + ' .ui.visible.bottom.sidebar ~ .fixed,'
  156. + ' .ui.visible.bottom.sidebar ~ .pusher {'
  157. + ' -webkit-transform: translate3d(0, -' + height + 'px, 0);'
  158. + ' transform: translate3d(0, -' + height + 'px, 0);'
  159. + ' }'
  160. + '</style>'
  161. ;
  162. $context.append(style);
  163. $style = $('style[title=' + namespace + ']');
  164. module.debug('Adding sizing css to head', $style);
  165. }
  166. },
  167. refresh: function() {
  168. module.verbose('Refreshing selector cache');
  169. $context = $(settings.context);
  170. $sidebars = $context.children(selector.sidebar);
  171. $pusher = $context.children(selector.pusher);
  172. },
  173. repaint: function() {
  174. module.verbose('Forcing repaint event');
  175. element.style.display='none';
  176. element.offsetHeight;
  177. element.scrollTop = element.scrollTop;
  178. element.style.display='';
  179. },
  180. setup: {
  181. layout: function() {
  182. if( $context.find(selector.pusher).size() === 0 ) {
  183. module.debug('Adding wrapper element for sidebar');
  184. $pusher = $('<div class="pusher" />');
  185. $context
  186. .children()
  187. .not(selector.omitted)
  188. .not($sidebars)
  189. .wrapAll($pusher)
  190. ;
  191. module.refresh();
  192. }
  193. if($module.nextAll(selector.pusher)[0] !== $pusher[0]) {
  194. module.debug('Moved sidebar to correct parent element');
  195. $module.detach().prependTo($context);
  196. module.refresh();
  197. }
  198. module.set.pushable();
  199. module.set.direction();
  200. }
  201. },
  202. attachEvents: function(selector, event) {
  203. var
  204. $toggle = $(selector)
  205. ;
  206. event = $.isFunction(module[event])
  207. ? module[event]
  208. : module.toggle
  209. ;
  210. if($toggle.size() > 0) {
  211. module.debug('Attaching sidebar events to element', selector, event);
  212. $toggle
  213. .on('click' + eventNamespace, event)
  214. ;
  215. }
  216. else {
  217. module.error(error.notFound, selector);
  218. }
  219. },
  220. show: function(callback) {
  221. var
  222. animateMethod = (settings.useLegacy)
  223. ? module.legacyPushPage
  224. : module.pushPage
  225. ;
  226. callback = $.isFunction(callback)
  227. ? callback
  228. : function(){}
  229. ;
  230. if(module.is.closed()) {
  231. if(settings.overlay) {
  232. module.error(error.overlay);
  233. settings.transition = 'overlay';
  234. }
  235. module.refresh();
  236. if(module.othersVisible() && module.get.transition() != 'overlay') {
  237. module.debug('Other sidebars currently open');
  238. if(settings.exclusive) {
  239. module.hideOthers();
  240. }
  241. }
  242. animateMethod(function() {
  243. $.proxy(callback, element)();
  244. $.proxy(settings.onShow, element)();
  245. });
  246. $.proxy(settings.onChange, element)();
  247. $.proxy(settings.onVisible, element)();
  248. }
  249. else {
  250. module.debug('Sidebar is already visible');
  251. }
  252. },
  253. hide: function(callback) {
  254. var
  255. animateMethod = (settings.useLegacy)
  256. ? module.legacyPullPage
  257. : module.pullPage
  258. ;
  259. callback = $.isFunction(callback)
  260. ? callback
  261. : function(){}
  262. ;
  263. if(module.is.visible() || module.is.animating()) {
  264. module.debug('Hiding sidebar', callback);
  265. animateMethod(function() {
  266. $.proxy(callback, element)();
  267. $.proxy(settings.onHidden, element)();
  268. });
  269. $.proxy(settings.onChange, element)();
  270. $.proxy(settings.onHide, element)();
  271. }
  272. },
  273. othersVisible: function() {
  274. return ($sidebars.not($module).filter('.' + className.visible).size() > 0);
  275. },
  276. othersActive: function() {
  277. return ($sidebars.not($module).filter('.' + className.active).size() > 0);
  278. },
  279. hideOthers: function(callback) {
  280. var
  281. $otherSidebars = $sidebars.not($module).filter('.' + className.visible),
  282. callback = callback || function(){},
  283. sidebarCount = $otherSidebars.size(),
  284. callbackCount = 0
  285. ;
  286. $otherSidebars
  287. .sidebar('hide', function() {
  288. callbackCount++;
  289. if(callbackCount == sidebarCount) {
  290. callback();
  291. }
  292. })
  293. ;
  294. },
  295. toggle: function() {
  296. module.verbose('Determining toggled direction');
  297. if(module.is.closed()) {
  298. module.show();
  299. }
  300. else {
  301. module.hide();
  302. }
  303. },
  304. pushPage: function(callback) {
  305. var
  306. transition = module.get.transition(),
  307. $transition = (transition == 'safe')
  308. ? $context
  309. : (transition == 'overlay' || module.othersActive())
  310. ? $module
  311. : $pusher,
  312. animate,
  313. transitionEnd
  314. ;
  315. callback = $.isFunction(callback)
  316. ? callback
  317. : function(){}
  318. ;
  319. if(settings.transition == 'scale down' || (module.is.mobile() && transition !== 'overlay')) {
  320. module.scrollToTop();
  321. }
  322. module.add.bodyCSS();
  323. module.set.transition();
  324. module.repaint();
  325. animate = function() {
  326. module.set.animating();
  327. requestAnimationFrame(function() {
  328. module.set.visible();
  329. if(!module.othersActive()) {
  330. if(settings.dimPage) {
  331. $pusher.addClass(className.dimmed);
  332. }
  333. }
  334. });
  335. };
  336. transitionEnd = function(event) {
  337. if( event.target == $transition[0] ) {
  338. $transition.off(transitionEvent + eventNamespace, transitionEnd);
  339. module.remove.animating();
  340. module.bind.clickaway();
  341. $.proxy(callback, element)();
  342. }
  343. };
  344. $transition.on(transitionEvent + eventNamespace, transitionEnd);
  345. requestAnimationFrame(animate);
  346. },
  347. pullPage: function(callback) {
  348. var
  349. transition = module.get.transition(),
  350. $transition = (transition == 'safe')
  351. ? $context
  352. : (transition == 'overlay' || module.othersActive())
  353. ? $module
  354. : $pusher,
  355. animate,
  356. transitionEnd
  357. ;
  358. callback = $.isFunction(callback)
  359. ? callback
  360. : function(){}
  361. ;
  362. module.verbose('Removing context push state', module.get.direction());
  363. if(!module.othersActive()) {
  364. module.unbind.clickaway();
  365. }
  366. animate = function() {
  367. module.set.animating();
  368. module.remove.visible();
  369. if(settings.dimPage && !module.othersActive()) {
  370. $pusher.removeClass(className.dimmed);
  371. }
  372. };
  373. transitionEnd = function(event) {
  374. if( event.target == $transition[0] ) {
  375. $transition.off(transitionEvent + eventNamespace, transitionEnd);
  376. module.remove.animating();
  377. module.remove.transition();
  378. module.remove.bodyCSS();
  379. if(transition == 'scale down' || (settings.returnScroll && transition !== 'overlay' && module.is.mobile()) ) {
  380. module.scrollBack();
  381. }
  382. $.proxy(callback, element)();
  383. }
  384. };
  385. $transition.on(transitionEvent + eventNamespace, transitionEnd);
  386. requestAnimationFrame(animate);
  387. },
  388. legacyPushPage: function(callback) {
  389. var
  390. distance = $module.width(),
  391. direction = module.get.direction(),
  392. properties = {}
  393. ;
  394. distance = distance || $module.width();
  395. callback = $.isFunction(callback)
  396. ? callback
  397. : function(){}
  398. ;
  399. properties[direction] = distance;
  400. module.debug('Using javascript to push context', properties);
  401. module.set.visible();
  402. module.set.transition();
  403. module.set.animating();
  404. if(settings.dimPage) {
  405. $pusher.addClass(className.dimmed);
  406. }
  407. $context
  408. .animate(properties, settings.duration, settings.easing, function() {
  409. module.remove.animating();
  410. module.bind.clickaway();
  411. $.proxy(callback, module)();
  412. })
  413. ;
  414. },
  415. legacyPullPage: function(callback) {
  416. var
  417. distance = 0,
  418. direction = module.get.direction(),
  419. properties = {}
  420. ;
  421. distance = distance || $module.width();
  422. callback = $.isFunction(callback)
  423. ? callback
  424. : function(){}
  425. ;
  426. properties[direction] = '0px';
  427. module.debug('Using javascript to pull context', properties);
  428. module.unbind.clickaway();
  429. module.set.animating();
  430. module.remove.visible();
  431. if(settings.dimPage && !module.othersVisible()) {
  432. $pusher.removeClass(className.dimmed);
  433. }
  434. $context
  435. .animate(properties, settings.duration, settings.easing, function() {
  436. module.remove.animating();
  437. $.proxy(callback, module)();
  438. })
  439. ;
  440. },
  441. scrollToTop: function() {
  442. module.verbose('Scrolling to top of page to avoid animation issues');
  443. $module.scrollTop(0);
  444. window.scrollTo(0, 0);
  445. },
  446. scrollBack: function() {
  447. module.verbose('Scrolling back to original page position');
  448. window.scrollTo(0, currentScroll);
  449. },
  450. set: {
  451. // container
  452. pushed: function() {
  453. $context.addClass(className.pushed);
  454. },
  455. pushable: function() {
  456. $context.addClass(className.pushable);
  457. },
  458. // sidebar
  459. active: function() {
  460. $module.addClass(className.active);
  461. },
  462. animating: function() {
  463. $module.addClass(className.animating);
  464. },
  465. transition: function(transition) {
  466. transition = transition || module.get.transition();
  467. $module.addClass(transition);
  468. },
  469. direction: function(direction) {
  470. direction = direction || module.get.direction();
  471. $module.addClass(className[direction]);
  472. },
  473. visible: function() {
  474. $module.addClass(className.visible);
  475. },
  476. overlay: function() {
  477. $module.addClass(className.overlay);
  478. }
  479. },
  480. remove: {
  481. bodyCSS: function() {
  482. module.debug('Removing body css styles', $style);
  483. if($style.size() > 0) {
  484. $style.remove();
  485. }
  486. },
  487. // context
  488. pushed: function() {
  489. $context.removeClass(className.pushed);
  490. },
  491. pushable: function() {
  492. $context.removeClass(className.pushable);
  493. },
  494. // sidebar
  495. active: function() {
  496. $module.removeClass(className.active);
  497. },
  498. animating: function() {
  499. $module.removeClass(className.animating);
  500. },
  501. transition: function(transition) {
  502. transition = transition || module.get.transition();
  503. $module.removeClass(transition);
  504. },
  505. direction: function(direction) {
  506. direction = direction || module.get.direction();
  507. $module.removeClass(className[direction]);
  508. },
  509. visible: function() {
  510. $module.removeClass(className.visible);
  511. },
  512. overlay: function() {
  513. $module.removeClass(className.overlay);
  514. }
  515. },
  516. get: {
  517. direction: function() {
  518. if($module.hasClass(className.top)) {
  519. return className.top;
  520. }
  521. else if($module.hasClass(className.right)) {
  522. return className.right;
  523. }
  524. else if($module.hasClass(className.bottom)) {
  525. return className.bottom;
  526. }
  527. return className.left;
  528. },
  529. transition: function() {
  530. var
  531. direction = module.get.direction(),
  532. transition
  533. ;
  534. return ( module.is.mobile() )
  535. ? (settings.mobileTransition == 'auto')
  536. ? settings.defaultTransition.mobile[direction]
  537. : settings.mobileTransition
  538. : (settings.transition == 'auto')
  539. ? settings.defaultTransition.computer[direction]
  540. : settings.transition
  541. ;
  542. },
  543. transitionEvent: function() {
  544. var
  545. element = document.createElement('element'),
  546. transitions = {
  547. 'transition' :'transitionend',
  548. 'OTransition' :'oTransitionEnd',
  549. 'MozTransition' :'transitionend',
  550. 'WebkitTransition' :'webkitTransitionEnd'
  551. },
  552. transition
  553. ;
  554. for(transition in transitions){
  555. if( element.style[transition] !== undefined ){
  556. return transitions[transition];
  557. }
  558. }
  559. }
  560. },
  561. is: {
  562. legacy: function() {
  563. var
  564. element = document.createElement('div'),
  565. transforms = {
  566. 'webkitTransform' :'-webkit-transform',
  567. 'OTransform' :'-o-transform',
  568. 'msTransform' :'-ms-transform',
  569. 'MozTransform' :'-moz-transform',
  570. 'transform' :'transform'
  571. },
  572. has3D
  573. ;
  574. // Add it to the body to get the computed style.
  575. document.body.insertBefore(element, null);
  576. for (var transform in transforms) {
  577. if (element.style[transform] !== undefined) {
  578. element.style[transform] = "translate3d(1px,1px,1px)";
  579. has3D = window.getComputedStyle(element).getPropertyValue(transforms[transform]);
  580. }
  581. }
  582. document.body.removeChild(element);
  583. return !(has3D !== undefined && has3D.length > 0 && has3D !== 'none');
  584. },
  585. mobile: function() {
  586. var
  587. userAgent = navigator.userAgent,
  588. mobileRegExp = /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/,
  589. isMobile = mobileRegExp.test(userAgent)
  590. ;
  591. if(isMobile) {
  592. module.verbose('Browser was found to be mobile', userAgent);
  593. return true;
  594. }
  595. else {
  596. module.verbose('Browser is not mobile, using regular transition', userAgent);
  597. return false;
  598. }
  599. },
  600. closed: function() {
  601. return !module.is.visible();
  602. },
  603. visible: function() {
  604. return $module.hasClass(className.visible);
  605. },
  606. vertical: function() {
  607. return $module.hasClass(className.top);
  608. },
  609. animating: function() {
  610. return $context.hasClass(className.animating);
  611. }
  612. },
  613. setting: function(name, value) {
  614. module.debug('Changing setting', name, value);
  615. if( $.isPlainObject(name) ) {
  616. $.extend(true, settings, name);
  617. }
  618. else if(value !== undefined) {
  619. settings[name] = value;
  620. }
  621. else {
  622. return settings[name];
  623. }
  624. },
  625. internal: function(name, value) {
  626. if( $.isPlainObject(name) ) {
  627. $.extend(true, module, name);
  628. }
  629. else if(value !== undefined) {
  630. module[name] = value;
  631. }
  632. else {
  633. return module[name];
  634. }
  635. },
  636. debug: function() {
  637. if(settings.debug) {
  638. if(settings.performance) {
  639. module.performance.log(arguments);
  640. }
  641. else {
  642. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  643. module.debug.apply(console, arguments);
  644. }
  645. }
  646. },
  647. verbose: function() {
  648. if(settings.verbose && settings.debug) {
  649. if(settings.performance) {
  650. module.performance.log(arguments);
  651. }
  652. else {
  653. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  654. module.verbose.apply(console, arguments);
  655. }
  656. }
  657. },
  658. error: function() {
  659. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  660. module.error.apply(console, arguments);
  661. },
  662. performance: {
  663. log: function(message) {
  664. var
  665. currentTime,
  666. executionTime,
  667. previousTime
  668. ;
  669. if(settings.performance) {
  670. currentTime = new Date().getTime();
  671. previousTime = time || currentTime;
  672. executionTime = currentTime - previousTime;
  673. time = currentTime;
  674. performance.push({
  675. 'Name' : message[0],
  676. 'Arguments' : [].slice.call(message, 1) || '',
  677. 'Element' : element,
  678. 'Execution Time' : executionTime
  679. });
  680. }
  681. clearTimeout(module.performance.timer);
  682. module.performance.timer = setTimeout(module.performance.display, 100);
  683. },
  684. display: function() {
  685. var
  686. title = settings.name + ':',
  687. totalTime = 0
  688. ;
  689. time = false;
  690. clearTimeout(module.performance.timer);
  691. $.each(performance, function(index, data) {
  692. totalTime += data['Execution Time'];
  693. });
  694. title += ' ' + totalTime + 'ms';
  695. if(moduleSelector) {
  696. title += ' \'' + moduleSelector + '\'';
  697. }
  698. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  699. console.groupCollapsed(title);
  700. if(console.table) {
  701. console.table(performance);
  702. }
  703. else {
  704. $.each(performance, function(index, data) {
  705. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  706. });
  707. }
  708. console.groupEnd();
  709. }
  710. performance = [];
  711. }
  712. },
  713. invoke: function(query, passedArguments, context) {
  714. var
  715. object = instance,
  716. maxDepth,
  717. found,
  718. response
  719. ;
  720. passedArguments = passedArguments || queryArguments;
  721. context = element || context;
  722. if(typeof query == 'string' && object !== undefined) {
  723. query = query.split(/[\. ]/);
  724. maxDepth = query.length - 1;
  725. $.each(query, function(depth, value) {
  726. var camelCaseValue = (depth != maxDepth)
  727. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  728. : query
  729. ;
  730. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  731. object = object[camelCaseValue];
  732. }
  733. else if( object[camelCaseValue] !== undefined ) {
  734. found = object[camelCaseValue];
  735. return false;
  736. }
  737. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  738. object = object[value];
  739. }
  740. else if( object[value] !== undefined ) {
  741. found = object[value];
  742. return false;
  743. }
  744. else {
  745. module.error(error.method, query);
  746. return false;
  747. }
  748. });
  749. }
  750. if ( $.isFunction( found ) ) {
  751. response = found.apply(context, passedArguments);
  752. }
  753. else if(found !== undefined) {
  754. response = found;
  755. }
  756. if($.isArray(returnedValue)) {
  757. returnedValue.push(response);
  758. }
  759. else if(returnedValue !== undefined) {
  760. returnedValue = [returnedValue, response];
  761. }
  762. else if(response !== undefined) {
  763. returnedValue = response;
  764. }
  765. return found;
  766. }
  767. }
  768. ;
  769. if(methodInvoked) {
  770. if(instance === undefined) {
  771. module.initialize();
  772. }
  773. module.invoke(query);
  774. }
  775. else {
  776. if(instance !== undefined) {
  777. module.invoke('destroy');
  778. }
  779. module.initialize();
  780. }
  781. });
  782. return (returnedValue !== undefined)
  783. ? returnedValue
  784. : this
  785. ;
  786. };
  787. $.fn.sidebar.settings = {
  788. name : 'Sidebar',
  789. namespace : 'sidebar',
  790. debug : false,
  791. verbose : true,
  792. performance : true,
  793. transition : 'auto',
  794. mobileTransition : 'auto',
  795. defaultTransition : {
  796. computer: {
  797. left : 'uncover',
  798. right : 'uncover',
  799. top : 'overlay',
  800. bottom : 'overlay'
  801. },
  802. mobile: {
  803. left : 'uncover',
  804. right : 'uncover',
  805. top : 'overlay',
  806. bottom : 'overlay'
  807. }
  808. },
  809. context : 'body',
  810. exclusive : false,
  811. closable : true,
  812. dimPage : true,
  813. scrollLock : false,
  814. returnScroll : true,
  815. useLegacy : false,
  816. duration : 500,
  817. easing : 'easeInOutQuint',
  818. onChange : function(){},
  819. onShow : function(){},
  820. onHide : function(){},
  821. onHidden : function(){},
  822. onVisible : function(){},
  823. className : {
  824. active : 'active',
  825. animating : 'animating',
  826. dimmed : 'dimmed',
  827. pushable : 'pushable',
  828. pushed : 'pushed',
  829. right : 'right',
  830. top : 'top',
  831. left : 'left',
  832. bottom : 'bottom',
  833. visible : 'visible'
  834. },
  835. selector: {
  836. fixed : '.fixed',
  837. omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
  838. pusher : '.pusher',
  839. sidebar : '.ui.sidebar'
  840. },
  841. error : {
  842. method : 'The method you called is not defined.',
  843. overlay : 'The overlay setting is no longer supported, use animation: overlay',
  844. notFound : 'There were no elements that matched the specified selector'
  845. }
  846. };
  847. // Adds easing
  848. $.extend( $.easing, {
  849. easeInOutQuint: function (x, t, b, c, d) {
  850. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  851. return c/2*((t-=2)*t*t*t*t + 2) + b;
  852. }
  853. });
  854. })( jQuery, window , document );