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.

911 lines
29 KiB

9 years ago
8 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 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
9 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 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
8 years ago
10 years ago
9 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
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
  1. /*!
  2. * # Semantic UI 2.2.0 - Progress
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2015 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. ;(function ($, window, document, undefined) {
  12. "use strict";
  13. window = (typeof window != 'undefined' && window.Math == Math)
  14. ? window
  15. : (typeof self != 'undefined' && self.Math == Math)
  16. ? self
  17. : Function('return this')()
  18. ;
  19. var
  20. global = (typeof window != 'undefined' && window.Math == Math)
  21. ? window
  22. : (typeof self != 'undefined' && self.Math == Math)
  23. ? self
  24. : Function('return this')()
  25. ;
  26. $.fn.progress = function(parameters) {
  27. var
  28. $allModules = $(this),
  29. moduleSelector = $allModules.selector || '',
  30. time = new Date().getTime(),
  31. performance = [],
  32. query = arguments[0],
  33. methodInvoked = (typeof query == 'string'),
  34. queryArguments = [].slice.call(arguments, 1),
  35. returnedValue
  36. ;
  37. $allModules
  38. .each(function() {
  39. var
  40. settings = ( $.isPlainObject(parameters) )
  41. ? $.extend(true, {}, $.fn.progress.settings, parameters)
  42. : $.extend({}, $.fn.progress.settings),
  43. className = settings.className,
  44. metadata = settings.metadata,
  45. namespace = settings.namespace,
  46. selector = settings.selector,
  47. error = settings.error,
  48. eventNamespace = '.' + namespace,
  49. moduleNamespace = 'module-' + namespace,
  50. $module = $(this),
  51. $bar = $(this).find(selector.bar),
  52. $progress = $(this).find(selector.progress),
  53. $label = $(this).find(selector.label),
  54. element = this,
  55. instance = $module.data(moduleNamespace),
  56. animating = false,
  57. transitionEnd,
  58. module
  59. ;
  60. module = {
  61. initialize: function() {
  62. module.debug('Initializing progress bar', settings);
  63. module.set.duration();
  64. module.set.transitionEvent();
  65. module.read.metadata();
  66. module.read.settings();
  67. module.instantiate();
  68. },
  69. instantiate: function() {
  70. module.verbose('Storing instance of progress', module);
  71. instance = module;
  72. $module
  73. .data(moduleNamespace, module)
  74. ;
  75. },
  76. destroy: function() {
  77. module.verbose('Destroying previous progress for', $module);
  78. clearInterval(instance.interval);
  79. module.remove.state();
  80. $module.removeData(moduleNamespace);
  81. instance = undefined;
  82. },
  83. reset: function() {
  84. module.remove.nextValue();
  85. module.update.progress(0);
  86. },
  87. complete: function() {
  88. if(module.percent === undefined || module.percent < 100) {
  89. module.remove.progressPoll();
  90. module.set.percent(100);
  91. }
  92. },
  93. read: {
  94. metadata: function() {
  95. var
  96. data = {
  97. percent : $module.data(metadata.percent),
  98. total : $module.data(metadata.total),
  99. value : $module.data(metadata.value)
  100. }
  101. ;
  102. if(data.percent) {
  103. module.debug('Current percent value set from metadata', data.percent);
  104. module.set.percent(data.percent);
  105. }
  106. if(data.total) {
  107. module.debug('Total value set from metadata', data.total);
  108. module.set.total(data.total);
  109. }
  110. if(data.value) {
  111. module.debug('Current value set from metadata', data.value);
  112. module.set.value(data.value);
  113. module.set.progress(data.value);
  114. }
  115. },
  116. settings: function() {
  117. if(settings.total !== false) {
  118. module.debug('Current total set in settings', settings.total);
  119. module.set.total(settings.total);
  120. }
  121. if(settings.value !== false) {
  122. module.debug('Current value set in settings', settings.value);
  123. module.set.value(settings.value);
  124. module.set.progress(module.value);
  125. }
  126. if(settings.percent !== false) {
  127. module.debug('Current percent set in settings', settings.percent);
  128. module.set.percent(settings.percent);
  129. }
  130. }
  131. },
  132. increment: function(incrementValue) {
  133. var
  134. maxValue,
  135. startValue,
  136. newValue
  137. ;
  138. if( module.has.total() ) {
  139. startValue = module.get.value();
  140. incrementValue = incrementValue || 1;
  141. newValue = startValue + incrementValue;
  142. }
  143. else {
  144. startValue = module.get.percent();
  145. incrementValue = incrementValue || module.get.randomValue();
  146. newValue = startValue + incrementValue;
  147. maxValue = 100;
  148. module.debug('Incrementing percentage by', startValue, newValue);
  149. }
  150. newValue = module.get.normalizedValue(newValue);
  151. module.set.progress(newValue);
  152. },
  153. decrement: function(decrementValue) {
  154. var
  155. total = module.get.total(),
  156. startValue,
  157. newValue
  158. ;
  159. if(total) {
  160. startValue = module.get.value();
  161. decrementValue = decrementValue || 1;
  162. newValue = startValue - decrementValue;
  163. module.debug('Decrementing value by', decrementValue, startValue);
  164. }
  165. else {
  166. startValue = module.get.percent();
  167. decrementValue = decrementValue || module.get.randomValue();
  168. newValue = startValue - decrementValue;
  169. module.debug('Decrementing percentage by', decrementValue, startValue);
  170. }
  171. newValue = module.get.normalizedValue(newValue);
  172. module.set.progress(newValue);
  173. },
  174. has: {
  175. progressPoll: function() {
  176. return module.progressPoll;
  177. },
  178. total: function() {
  179. return (module.get.total() !== false);
  180. }
  181. },
  182. get: {
  183. text: function(templateText) {
  184. var
  185. value = module.value || 0,
  186. total = module.total || 0,
  187. percent = (animating)
  188. ? module.get.displayPercent()
  189. : module.percent || 0,
  190. left = (module.total > 0)
  191. ? (total - value)
  192. : (100 - percent)
  193. ;
  194. templateText = templateText || '';
  195. templateText = templateText
  196. .replace('{value}', value)
  197. .replace('{total}', total)
  198. .replace('{left}', left)
  199. .replace('{percent}', percent)
  200. ;
  201. module.verbose('Adding variables to progress bar text', templateText);
  202. return templateText;
  203. },
  204. normalizedValue: function(value) {
  205. if(value < 0) {
  206. module.debug('Value cannot decrement below 0');
  207. return 0;
  208. }
  209. if(module.has.total()) {
  210. if(value > module.total) {
  211. module.debug('Value cannot increment above total', module.total);
  212. return module.total;
  213. }
  214. }
  215. else if(value > 100 ) {
  216. module.debug('Value cannot increment above 100 percent');
  217. return 100;
  218. }
  219. return value;
  220. },
  221. updateInterval: function() {
  222. if(settings.updateInterval == 'auto') {
  223. return settings.duration;
  224. }
  225. return settings.updateInterval;
  226. },
  227. randomValue: function() {
  228. module.debug('Generating random increment percentage');
  229. return Math.floor((Math.random() * settings.random.max) + settings.random.min);
  230. },
  231. numericValue: function(value) {
  232. return (typeof value === 'string')
  233. ? (value.replace(/[^\d.]/g, '') !== '')
  234. ? +(value.replace(/[^\d.]/g, ''))
  235. : false
  236. : value
  237. ;
  238. },
  239. transitionEnd: function() {
  240. var
  241. element = document.createElement('element'),
  242. transitions = {
  243. 'transition' :'transitionend',
  244. 'OTransition' :'oTransitionEnd',
  245. 'MozTransition' :'transitionend',
  246. 'WebkitTransition' :'webkitTransitionEnd'
  247. },
  248. transition
  249. ;
  250. for(transition in transitions){
  251. if( element.style[transition] !== undefined ){
  252. return transitions[transition];
  253. }
  254. }
  255. },
  256. // gets current displayed percentage (if animating values this is the intermediary value)
  257. displayPercent: function() {
  258. var
  259. barWidth = $bar.width(),
  260. totalWidth = $module.width(),
  261. minDisplay = parseInt($bar.css('min-width'), 10),
  262. displayPercent = (barWidth > minDisplay)
  263. ? (barWidth / totalWidth * 100)
  264. : module.percent
  265. ;
  266. return (settings.precision > 0)
  267. ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
  268. : Math.round(displayPercent)
  269. ;
  270. },
  271. percent: function() {
  272. return module.percent || 0;
  273. },
  274. value: function() {
  275. return module.nextValue || module.value || 0;
  276. },
  277. total: function() {
  278. return module.total || false;
  279. }
  280. },
  281. create: {
  282. progressPoll: function() {
  283. module.progressPoll = setTimeout(function() {
  284. module.update.toNextValue();
  285. module.remove.progressPoll();
  286. }, module.get.updateInterval());
  287. },
  288. },
  289. is: {
  290. complete: function() {
  291. return module.is.success() || module.is.warning() || module.is.error();
  292. },
  293. success: function() {
  294. return $module.hasClass(className.success);
  295. },
  296. warning: function() {
  297. return $module.hasClass(className.warning);
  298. },
  299. error: function() {
  300. return $module.hasClass(className.error);
  301. },
  302. active: function() {
  303. return $module.hasClass(className.active);
  304. },
  305. visible: function() {
  306. return $module.is(':visible');
  307. }
  308. },
  309. remove: {
  310. progressPoll: function() {
  311. module.verbose('Removing progress poll timer');
  312. if(module.progressPoll) {
  313. clearTimeout(module.progressPoll);
  314. delete module.progressPoll;
  315. }
  316. },
  317. nextValue: function() {
  318. module.verbose('Removing progress value stored for next update');
  319. delete module.nextValue;
  320. },
  321. state: function() {
  322. module.verbose('Removing stored state');
  323. delete module.total;
  324. delete module.percent;
  325. delete module.value;
  326. },
  327. active: function() {
  328. module.verbose('Removing active state');
  329. $module.removeClass(className.active);
  330. },
  331. success: function() {
  332. module.verbose('Removing success state');
  333. $module.removeClass(className.success);
  334. },
  335. warning: function() {
  336. module.verbose('Removing warning state');
  337. $module.removeClass(className.warning);
  338. },
  339. error: function() {
  340. module.verbose('Removing error state');
  341. $module.removeClass(className.error);
  342. }
  343. },
  344. set: {
  345. barWidth: function(value) {
  346. if(value > 100) {
  347. module.error(error.tooHigh, value);
  348. }
  349. else if (value < 0) {
  350. module.error(error.tooLow, value);
  351. }
  352. else {
  353. $bar
  354. .css('width', value + '%')
  355. ;
  356. $module
  357. .attr('data-percent', parseInt(value, 10))
  358. ;
  359. }
  360. },
  361. duration: function(duration) {
  362. duration = duration || settings.duration;
  363. duration = (typeof duration == 'number')
  364. ? duration + 'ms'
  365. : duration
  366. ;
  367. module.verbose('Setting progress bar transition duration', duration);
  368. $bar
  369. .css({
  370. 'transition-duration': duration
  371. })
  372. ;
  373. },
  374. percent: function(percent) {
  375. percent = (typeof percent == 'string')
  376. ? +(percent.replace('%', ''))
  377. : percent
  378. ;
  379. // round display percentage
  380. percent = (settings.precision > 0)
  381. ? Math.round(percent * (10 * settings.precision)) / (10 * settings.precision)
  382. : Math.round(percent)
  383. ;
  384. module.percent = percent;
  385. if( !module.has.total() ) {
  386. module.value = (settings.precision > 0)
  387. ? Math.round( (percent / 100) * module.total * (10 * settings.precision)) / (10 * settings.precision)
  388. : Math.round( (percent / 100) * module.total * 10) / 10
  389. ;
  390. if(settings.limitValues) {
  391. module.value = (module.value > 100)
  392. ? 100
  393. : (module.value < 0)
  394. ? 0
  395. : module.value
  396. ;
  397. }
  398. }
  399. module.set.barWidth(percent);
  400. module.set.labelInterval();
  401. module.set.labels();
  402. settings.onChange.call(element, percent, module.value, module.total);
  403. },
  404. labelInterval: function() {
  405. var
  406. animationCallback = function() {
  407. module.verbose('Bar finished animating, removing continuous label updates');
  408. clearInterval(module.interval);
  409. animating = false;
  410. module.set.labels();
  411. }
  412. ;
  413. clearInterval(module.interval);
  414. $bar.one(transitionEnd + eventNamespace, animationCallback);
  415. animating = true;
  416. module.interval = setInterval(function() {
  417. let
  418. isInDOM = $.contains(document.documentElement, element)
  419. ;
  420. if(!isInDOM) {
  421. clearInterval(module.interval);
  422. animating = false;
  423. }
  424. module.set.labels();
  425. }, settings.framerate);
  426. },
  427. labels: function() {
  428. module.verbose('Setting both bar progress and outer label text');
  429. module.set.barLabel();
  430. module.set.state();
  431. },
  432. label: function(text) {
  433. text = text || '';
  434. if(text) {
  435. text = module.get.text(text);
  436. module.verbose('Setting label to text', text);
  437. $label.text(text);
  438. }
  439. },
  440. state: function(percent) {
  441. percent = (percent !== undefined)
  442. ? percent
  443. : module.percent
  444. ;
  445. if(percent === 100) {
  446. if(settings.autoSuccess && !(module.is.warning() || module.is.error() || module.is.success())) {
  447. module.set.success();
  448. module.debug('Automatically triggering success at 100%');
  449. }
  450. else {
  451. module.verbose('Reached 100% removing active state');
  452. module.remove.active();
  453. module.remove.progressPoll();
  454. }
  455. }
  456. else if(percent > 0) {
  457. module.verbose('Adjusting active progress bar label', percent);
  458. module.set.active();
  459. }
  460. else {
  461. module.remove.active();
  462. module.set.label(settings.text.active);
  463. }
  464. },
  465. barLabel: function(text) {
  466. if(text !== undefined) {
  467. $progress.text( module.get.text(text) );
  468. }
  469. else if(settings.label == 'ratio' && module.total) {
  470. module.verbose('Adding ratio to bar label');
  471. $progress.text( module.get.text(settings.text.ratio) );
  472. }
  473. else if(settings.label == 'percent') {
  474. module.verbose('Adding percentage to bar label');
  475. $progress.text( module.get.text(settings.text.percent) );
  476. }
  477. },
  478. active: function(text) {
  479. text = text || settings.text.active;
  480. module.debug('Setting active state');
  481. if(settings.showActivity && !module.is.active() ) {
  482. $module.addClass(className.active);
  483. }
  484. module.remove.warning();
  485. module.remove.error();
  486. module.remove.success();
  487. text = settings.onLabelUpdate('active', text, module.value, module.total);
  488. if(text) {
  489. module.set.label(text);
  490. }
  491. $bar.one(transitionEnd + eventNamespace, function() {
  492. settings.onActive.call(element, module.value, module.total);
  493. });
  494. },
  495. success : function(text) {
  496. text = text || settings.text.success || settings.text.active;
  497. module.debug('Setting success state');
  498. $module.addClass(className.success);
  499. module.remove.active();
  500. module.remove.warning();
  501. module.remove.error();
  502. module.complete();
  503. if(settings.text.success) {
  504. text = settings.onLabelUpdate('success', text, module.value, module.total);
  505. module.set.label(text);
  506. }
  507. else {
  508. text = settings.onLabelUpdate('active', text, module.value, module.total);
  509. module.set.label(text);
  510. }
  511. $bar.one(transitionEnd + eventNamespace, function() {
  512. settings.onSuccess.call(element, module.total);
  513. });
  514. },
  515. warning : function(text) {
  516. text = text || settings.text.warning;
  517. module.debug('Setting warning state');
  518. $module.addClass(className.warning);
  519. module.remove.active();
  520. module.remove.success();
  521. module.remove.error();
  522. module.complete();
  523. text = settings.onLabelUpdate('warning', text, module.value, module.total);
  524. if(text) {
  525. module.set.label(text);
  526. }
  527. $bar.one(transitionEnd + eventNamespace, function() {
  528. settings.onWarning.call(element, module.value, module.total);
  529. });
  530. },
  531. error : function(text) {
  532. text = text || settings.text.error;
  533. module.debug('Setting error state');
  534. $module.addClass(className.error);
  535. module.remove.active();
  536. module.remove.success();
  537. module.remove.warning();
  538. module.complete();
  539. text = settings.onLabelUpdate('error', text, module.value, module.total);
  540. if(text) {
  541. module.set.label(text);
  542. }
  543. $bar.one(transitionEnd + eventNamespace, function() {
  544. settings.onError.call(element, module.value, module.total);
  545. });
  546. },
  547. transitionEvent: function() {
  548. transitionEnd = module.get.transitionEnd();
  549. },
  550. total: function(totalValue) {
  551. module.total = totalValue;
  552. },
  553. value: function(value) {
  554. module.value = value;
  555. },
  556. progress: function(value) {
  557. if(!module.has.progressPoll()) {
  558. module.debug('First update in progress update interval, immediately updating', value);
  559. module.update.progress(value);
  560. module.create.progressPoll();
  561. }
  562. else {
  563. module.debug('Updated within interval, setting next update to use new value', value);
  564. module.set.nextValue(value);
  565. }
  566. },
  567. nextValue: function(value) {
  568. module.nextValue = value;
  569. }
  570. },
  571. update: {
  572. toNextValue: function() {
  573. var
  574. nextValue = module.nextValue
  575. ;
  576. if(nextValue) {
  577. module.debug('Update interval complete using last updated value', nextValue);
  578. module.update.progress(nextValue);
  579. module.remove.nextValue();
  580. }
  581. },
  582. progress: function(value) {
  583. var
  584. percentComplete
  585. ;
  586. value = module.get.numericValue(value);
  587. if(value === false) {
  588. module.error(error.nonNumeric, value);
  589. }
  590. value = module.get.normalizedValue(value);
  591. if( module.has.total() ) {
  592. module.set.value(value);
  593. percentComplete = (value / module.total) * 100;
  594. module.debug('Calculating percent complete from total', percentComplete);
  595. module.set.percent( percentComplete );
  596. }
  597. else {
  598. percentComplete = value;
  599. module.debug('Setting value to exact percentage value', percentComplete);
  600. module.set.percent( percentComplete );
  601. }
  602. }
  603. },
  604. setting: function(name, value) {
  605. module.debug('Changing setting', name, value);
  606. if( $.isPlainObject(name) ) {
  607. $.extend(true, settings, name);
  608. }
  609. else if(value !== undefined) {
  610. if($.isPlainObject(settings[name])) {
  611. $.extend(true, settings[name], value);
  612. }
  613. else {
  614. settings[name] = value;
  615. }
  616. }
  617. else {
  618. return settings[name];
  619. }
  620. },
  621. internal: function(name, value) {
  622. if( $.isPlainObject(name) ) {
  623. $.extend(true, module, name);
  624. }
  625. else if(value !== undefined) {
  626. module[name] = value;
  627. }
  628. else {
  629. return module[name];
  630. }
  631. },
  632. debug: function() {
  633. if(!settings.silent && settings.debug) {
  634. if(settings.performance) {
  635. module.performance.log(arguments);
  636. }
  637. else {
  638. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  639. module.debug.apply(console, arguments);
  640. }
  641. }
  642. },
  643. verbose: function() {
  644. if(!settings.silent && settings.verbose && settings.debug) {
  645. if(settings.performance) {
  646. module.performance.log(arguments);
  647. }
  648. else {
  649. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  650. module.verbose.apply(console, arguments);
  651. }
  652. }
  653. },
  654. error: function() {
  655. if(!settings.silent) {
  656. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  657. module.error.apply(console, arguments);
  658. }
  659. },
  660. performance: {
  661. log: function(message) {
  662. var
  663. currentTime,
  664. executionTime,
  665. previousTime
  666. ;
  667. if(settings.performance) {
  668. currentTime = new Date().getTime();
  669. previousTime = time || currentTime;
  670. executionTime = currentTime - previousTime;
  671. time = currentTime;
  672. performance.push({
  673. 'Name' : message[0],
  674. 'Arguments' : [].slice.call(message, 1) || '',
  675. 'Element' : element,
  676. 'Execution Time' : executionTime
  677. });
  678. }
  679. clearTimeout(module.performance.timer);
  680. module.performance.timer = setTimeout(module.performance.display, 500);
  681. },
  682. display: function() {
  683. var
  684. title = settings.name + ':',
  685. totalTime = 0
  686. ;
  687. time = false;
  688. clearTimeout(module.performance.timer);
  689. $.each(performance, function(index, data) {
  690. totalTime += data['Execution Time'];
  691. });
  692. title += ' ' + totalTime + 'ms';
  693. if(moduleSelector) {
  694. title += ' \'' + moduleSelector + '\'';
  695. }
  696. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  697. console.groupCollapsed(title);
  698. if(console.table) {
  699. console.table(performance);
  700. }
  701. else {
  702. $.each(performance, function(index, data) {
  703. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  704. });
  705. }
  706. console.groupEnd();
  707. }
  708. performance = [];
  709. }
  710. },
  711. invoke: function(query, passedArguments, context) {
  712. var
  713. object = instance,
  714. maxDepth,
  715. found,
  716. response
  717. ;
  718. passedArguments = passedArguments || queryArguments;
  719. context = element || context;
  720. if(typeof query == 'string' && object !== undefined) {
  721. query = query.split(/[\. ]/);
  722. maxDepth = query.length - 1;
  723. $.each(query, function(depth, value) {
  724. var camelCaseValue = (depth != maxDepth)
  725. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  726. : query
  727. ;
  728. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  729. object = object[camelCaseValue];
  730. }
  731. else if( object[camelCaseValue] !== undefined ) {
  732. found = object[camelCaseValue];
  733. return false;
  734. }
  735. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  736. object = object[value];
  737. }
  738. else if( object[value] !== undefined ) {
  739. found = object[value];
  740. return false;
  741. }
  742. else {
  743. module.error(error.method, query);
  744. return false;
  745. }
  746. });
  747. }
  748. if ( $.isFunction( found ) ) {
  749. response = found.apply(context, passedArguments);
  750. }
  751. else if(found !== undefined) {
  752. response = found;
  753. }
  754. if($.isArray(returnedValue)) {
  755. returnedValue.push(response);
  756. }
  757. else if(returnedValue !== undefined) {
  758. returnedValue = [returnedValue, response];
  759. }
  760. else if(response !== undefined) {
  761. returnedValue = response;
  762. }
  763. return found;
  764. }
  765. };
  766. if(methodInvoked) {
  767. if(instance === undefined) {
  768. module.initialize();
  769. }
  770. module.invoke(query);
  771. }
  772. else {
  773. if(instance !== undefined) {
  774. instance.invoke('destroy');
  775. }
  776. module.initialize();
  777. }
  778. })
  779. ;
  780. return (returnedValue !== undefined)
  781. ? returnedValue
  782. : this
  783. ;
  784. };
  785. $.fn.progress.settings = {
  786. name : 'Progress',
  787. namespace : 'progress',
  788. silent : false,
  789. debug : false,
  790. verbose : false,
  791. performance : true,
  792. random : {
  793. min : 2,
  794. max : 5
  795. },
  796. duration : 300,
  797. updateInterval : 'auto',
  798. autoSuccess : true,
  799. showActivity : true,
  800. limitValues : true,
  801. label : 'percent',
  802. precision : 0,
  803. framerate : (1000 / 30), /// 30 fps
  804. percent : false,
  805. total : false,
  806. value : false,
  807. onLabelUpdate : function(state, text, value, total){
  808. return text;
  809. },
  810. onChange : function(percent, value, total){},
  811. onSuccess : function(total){},
  812. onActive : function(value, total){},
  813. onError : function(value, total){},
  814. onWarning : function(value, total){},
  815. error : {
  816. method : 'The method you called is not defined.',
  817. nonNumeric : 'Progress value is non numeric',
  818. tooHigh : 'Value specified is above 100%',
  819. tooLow : 'Value specified is below 0%'
  820. },
  821. regExp: {
  822. variable: /\{\$*[A-z0-9]+\}/g
  823. },
  824. metadata: {
  825. percent : 'percent',
  826. total : 'total',
  827. value : 'value'
  828. },
  829. selector : {
  830. bar : '> .bar',
  831. label : '> .label',
  832. progress : '.bar > .progress'
  833. },
  834. text : {
  835. active : false,
  836. error : false,
  837. success : false,
  838. warning : false,
  839. percent : '{percent}%',
  840. ratio : '{value} of {total}'
  841. },
  842. className : {
  843. active : 'active',
  844. error : 'error',
  845. success : 'success',
  846. warning : 'warning'
  847. }
  848. };
  849. })( jQuery, window, document );