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.

910 lines
29 KiB

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