From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- node_modules/montage/core/bitfield.js | 199 + .../montage/core/converter/bytes-converter.js | 123 + node_modules/montage/core/converter/converter.js | 144 + .../montage/core/converter/currency-converter.js | 77 + .../montage/core/converter/date-converter.js | 2621 +++++++++++++ .../montage/core/converter/lower-case-converter.js | 46 + .../core/converter/new-line-to-br-converter.js | 60 + .../montage/core/converter/number-converter.js | 390 ++ .../montage/core/converter/trim-converter.js | 73 + .../montage/core/converter/upper-case-converter.js | 51 + node_modules/montage/core/core.js | 1122 ++++++ node_modules/montage/core/deserializer.js | 783 ++++ node_modules/montage/core/enum.js | 86 + .../montage/core/event/action-event-listener.js | 76 + node_modules/montage/core/event/binding.js | 1413 +++++++ node_modules/montage/core/event/event-manager.js | 2075 ++++++++++ node_modules/montage/core/event/mutable-event.js | 234 ++ node_modules/montage/core/exception.js | 95 + node_modules/montage/core/gate.js | 195 + node_modules/montage/core/geometry/cubic-bezier.js | 158 + node_modules/montage/core/geometry/point.js | 66 + node_modules/montage/core/jshint.js | 3945 ++++++++++++++++++++ node_modules/montage/core/logger.js | 493 +++ node_modules/montage/core/promise.js | 694 ++++ node_modules/montage/core/serializer.js | 452 +++ node_modules/montage/core/shim.js | 14 + node_modules/montage/core/shim/array.js | 78 + node_modules/montage/core/shim/string.js | 66 + node_modules/montage/core/shim/structures.js | 552 +++ node_modules/montage/core/shim/timers.js | 87 + node_modules/montage/core/shim/weak-map.js | 454 +++ node_modules/montage/core/state-chart.js | 595 +++ node_modules/montage/core/undo-manager.js | 240 ++ node_modules/montage/core/url.js | 317 ++ node_modules/montage/core/uuid.js | 74 + node_modules/montage/data/blueprint.js | 1062 ++++++ node_modules/montage/data/context.js | 374 ++ node_modules/montage/data/controllistener.js | 47 + .../montage/data/ldapaccess/ldapblueprint.js | 135 + .../montage/data/ldapaccess/ldapobjectid.js | 20 + .../data/ldapaccess/ldapselectorevaluator.js | 24 + node_modules/montage/data/ldapaccess/ldapstore.js | 38 + .../montage/data/nosqlaccess/nosqlblueprint.js | 135 + .../montage/data/nosqlaccess/nosqlobjectid.js | 22 + .../data/nosqlaccess/nosqlselectorevaluator.js | 24 + .../montage/data/nosqlaccess/nosqlstore.js | 68 + node_modules/montage/data/objectid.js | 77 + node_modules/montage/data/objectproperty.js | 298 ++ node_modules/montage/data/pledge.js | 270 ++ node_modules/montage/data/query.js | 114 + .../montage/data/restaccess/restblueprint.js | 138 + .../montage/data/restaccess/restobjectid.js | 21 + .../data/restaccess/restselectorevaluator.js | 24 + node_modules/montage/data/restaccess/reststore.js | 186 + node_modules/montage/data/restriction.js | 66 + node_modules/montage/data/selector.js | 2220 +++++++++++ .../montage/data/sqlaccess/sqlblueprint.js | 135 + node_modules/montage/data/sqlaccess/sqlobjectid.js | 22 + .../montage/data/sqlaccess/sqlselectorevaluator.js | 24 + node_modules/montage/data/sqlaccess/sqlstore.js | 69 + node_modules/montage/data/store.js | 1211 ++++++ node_modules/montage/data/transactionid.js | 230 ++ node_modules/montage/effect/desaturate-effect.js | 25 + node_modules/montage/effect/effect.js | 15 + node_modules/montage/effect/invert-effect.js | 23 + node_modules/montage/effect/kaliedoscope-effect.js | 17 + node_modules/montage/effect/multiply-effect.js | 23 + node_modules/montage/effect/sepia-effect.js | 25 + node_modules/montage/montage.js | 362 ++ node_modules/montage/package.json | 16 + node_modules/montage/require/browser.js | 239 ++ node_modules/montage/require/require.js | 871 +++++ node_modules/montage/service/service.js | 10 + node_modules/montage/ui/application.js | 248 ++ .../montage/ui/button-group.reel/button-group.css | 111 + .../montage/ui/button-group.reel/button-group.html | 26 + .../montage/ui/button-group.reel/button-group.js | 77 + node_modules/montage/ui/button.reel/button.css | 386 ++ node_modules/montage/ui/button.reel/button.html | 26 + node_modules/montage/ui/button.reel/button.js | 741 ++++ node_modules/montage/ui/checkbox.reel/checkbox.css | 116 + .../montage/ui/checkbox.reel/checkbox.html | 14 + node_modules/montage/ui/checkbox.reel/checkbox.js | 452 +++ .../ui/checkbox.reel/checkmark-dark-disabled.svg | 5 + .../montage/ui/checkbox.reel/checkmark-dark.svg | 7 + .../ui/checkbox.reel/checkmark-light-disabled.svg | 5 + .../montage/ui/checkbox.reel/checkmark.svg | 7 + .../ui/component-group.reel/component-group.js | 33 + .../component-placeholder.js | 146 + node_modules/montage/ui/component.js | 1527 ++++++++ .../montage/ui/condition.reel/condition.js | 149 + .../montage/ui/controller/array-controller.js | 796 ++++ .../montage/ui/controller/media-controller.js | 698 ++++ .../montage/ui/controller/object-controller.js | 62 + .../ui/controller/paged-array-controller.js | 260 ++ node_modules/montage/ui/dom.js | 268 ++ .../montage/ui/dynamic-text.reel/dynamic-text.js | 95 + node_modules/montage/ui/editable-text.js | 324 ++ .../ui/flow-controller.reel/flow-controller.html | 275 ++ .../ui/flow-controller.reel/flow-controller.js | 288 ++ node_modules/montage/ui/flow-offset.js | 389 ++ node_modules/montage/ui/flow-path-cubic.js | 115 + node_modules/montage/ui/flow-path-lerp.js | 112 + node_modules/montage/ui/flow-path-linear.js | 83 + node_modules/montage/ui/flow-path-sigmoid.js | 148 + node_modules/montage/ui/flow-path.js | 215 ++ node_modules/montage/ui/flow.reel/flow.html | 60 + node_modules/montage/ui/flow.reel/flow.js | 348 ++ node_modules/montage/ui/hottext.reel/hottext.css | 27 + node_modules/montage/ui/hottext.reel/hottext.html | 29 + node_modules/montage/ui/hottext.reel/hottext.js | 376 ++ .../montage/ui/hottextunit.reel/hottextunit.css | 41 + .../montage/ui/hottextunit.reel/hottextunit.html | 28 + .../montage/ui/hottextunit.reel/hottextunit.js | 185 + node_modules/montage/ui/image.reel/image.js | 65 + node_modules/montage/ui/image2.reel/image2.html | 31 + node_modules/montage/ui/image2.reel/image2.js | 26 + node_modules/montage/ui/image3d.reel/image3d.html | 95 + node_modules/montage/ui/image3d.reel/image3d.js | 30 + node_modules/montage/ui/list.reel/list.html | 56 + node_modules/montage/ui/list.reel/list.js | 272 ++ node_modules/montage/ui/loader.reel/loader.js | 472 +++ .../ui/loading-panel.reel/loading-panel.css | 37 + .../ui/loading-panel.reel/loading-panel.html | 89 + .../montage/ui/loading-panel.reel/loading-panel.js | 38 + node_modules/montage/ui/loading.reel/loading-0.svg | 3 + node_modules/montage/ui/loading.reel/loading-1.svg | 3 + node_modules/montage/ui/loading.reel/loading-2.svg | 3 + node_modules/montage/ui/loading.reel/loading-3.svg | 3 + node_modules/montage/ui/loading.reel/loading-4.svg | 3 + node_modules/montage/ui/loading.reel/loading-5.svg | 3 + .../montage/ui/loading.reel/loading-bg.svg | 31 + node_modules/montage/ui/loading.reel/loading.css | 78 + node_modules/montage/ui/loading.reel/loading.html | 36 + node_modules/montage/ui/loading.reel/loading.js | 61 + .../ui/nearest-neighbor-component-search.js | 232 ++ .../montage/ui/photo-editor.reel/photo-editor.css | 34 + .../montage/ui/photo-editor.reel/photo-editor.html | 50 + .../montage/ui/photo-editor.reel/photo-editor.js | 415 ++ node_modules/montage/ui/popup/alert.reel/alert.css | 67 + .../montage/ui/popup/alert.reel/alert.html | 120 + node_modules/montage/ui/popup/alert.reel/alert.js | 134 + .../montage/ui/popup/confirm.reel/confirm.css | 17 + .../montage/ui/popup/confirm.reel/confirm.html | 120 + .../montage/ui/popup/confirm.reel/confirm.js | 186 + .../montage/ui/popup/notifier.reel/notifier.css | 15 + .../montage/ui/popup/notifier.reel/notifier.html | 35 + .../montage/ui/popup/notifier.reel/notifier.js | 121 + node_modules/montage/ui/popup/popup.reel/popup.css | 70 + .../montage/ui/popup/popup.reel/popup.html | 54 + node_modules/montage/ui/popup/popup.reel/popup.js | 519 +++ node_modules/montage/ui/progress.reel/progress.css | 51 + .../montage/ui/progress.reel/progress.html | 32 + node_modules/montage/ui/progress.reel/progress.js | 140 + node_modules/montage/ui/progress.reel/rule.png | Bin 0 -> 956 bytes node_modules/montage/ui/progress.reel/scroll.png | Bin 0 -> 272 bytes .../montage/ui/repetition.reel/repetition.js | 1115 ++++++ .../montage/ui/scroll-bars.reel/scroll-bars.html | 117 + .../montage/ui/scroll-bars.reel/scroll-bars.js | 247 ++ node_modules/montage/ui/scroll.js | 820 ++++ .../montage/ui/scroller.reel/scroller.html | 55 + node_modules/montage/ui/scroller.reel/scroller.js | 268 ++ .../montage/ui/scrollview.reel/scrollview.js | 1230 ++++++ node_modules/montage/ui/slider-base.js | 278 ++ node_modules/montage/ui/slider.reel/slider.css | 255 ++ node_modules/montage/ui/slider.reel/slider.html | 82 + node_modules/montage/ui/slider.reel/slider.js | 583 +++ node_modules/montage/ui/slot.reel/slot.js | 302 ++ .../montage/ui/substitution.reel/substitution.js | 91 + node_modules/montage/ui/tabs.reel/tabs.css | 126 + node_modules/montage/ui/tabs.reel/tabs.html | 80 + node_modules/montage/ui/tabs.reel/tabs.js | 177 + node_modules/montage/ui/template.js | 792 ++++ node_modules/montage/ui/textarea.reel/textarea.css | 36 + .../montage/ui/textarea.reel/textarea.html | 15 + node_modules/montage/ui/textarea.reel/textarea.js | 29 + .../montage/ui/textfield.reel/textfield.css | 35 + .../montage/ui/textfield.reel/textfield.html | 16 + .../montage/ui/textfield.reel/textfield.js | 38 + node_modules/montage/ui/toggle.reel/toggle.css | 162 + node_modules/montage/ui/toggle.reel/toggle.html | 16 + node_modules/montage/ui/toggle.reel/toggle.js | 423 +++ .../video-player.reel/images/fullscreen-enter.png | Bin 0 -> 1178 bytes .../video-player.reel/images/fullscreen-exit.png | Bin 0 -> 1214 bytes .../montage/ui/video-player.reel/images/pause.png | Bin 0 -> 1040 bytes .../montage/ui/video-player.reel/images/play.png | Bin 0 -> 1375 bytes .../ui/video-player.reel/images/volume-down.png | Bin 0 -> 991 bytes .../ui/video-player.reel/images/volume-up.png | Bin 0 -> 1094 bytes .../montage/ui/video-player.reel/video-player.css | 313 ++ .../montage/ui/video-player.reel/video-player.html | 371 ++ .../montage/ui/video-player.reel/video-player.js | 368 ++ 191 files changed, 48413 insertions(+) create mode 100755 node_modules/montage/core/bitfield.js create mode 100755 node_modules/montage/core/converter/bytes-converter.js create mode 100755 node_modules/montage/core/converter/converter.js create mode 100755 node_modules/montage/core/converter/currency-converter.js create mode 100755 node_modules/montage/core/converter/date-converter.js create mode 100755 node_modules/montage/core/converter/lower-case-converter.js create mode 100755 node_modules/montage/core/converter/new-line-to-br-converter.js create mode 100755 node_modules/montage/core/converter/number-converter.js create mode 100755 node_modules/montage/core/converter/trim-converter.js create mode 100755 node_modules/montage/core/converter/upper-case-converter.js create mode 100755 node_modules/montage/core/core.js create mode 100755 node_modules/montage/core/deserializer.js create mode 100755 node_modules/montage/core/enum.js create mode 100755 node_modules/montage/core/event/action-event-listener.js create mode 100755 node_modules/montage/core/event/binding.js create mode 100755 node_modules/montage/core/event/event-manager.js create mode 100755 node_modules/montage/core/event/mutable-event.js create mode 100755 node_modules/montage/core/exception.js create mode 100755 node_modules/montage/core/gate.js create mode 100755 node_modules/montage/core/geometry/cubic-bezier.js create mode 100755 node_modules/montage/core/geometry/point.js create mode 100755 node_modules/montage/core/jshint.js create mode 100755 node_modules/montage/core/logger.js create mode 100755 node_modules/montage/core/promise.js create mode 100755 node_modules/montage/core/serializer.js create mode 100755 node_modules/montage/core/shim.js create mode 100755 node_modules/montage/core/shim/array.js create mode 100755 node_modules/montage/core/shim/string.js create mode 100755 node_modules/montage/core/shim/structures.js create mode 100755 node_modules/montage/core/shim/timers.js create mode 100755 node_modules/montage/core/shim/weak-map.js create mode 100755 node_modules/montage/core/state-chart.js create mode 100644 node_modules/montage/core/undo-manager.js create mode 100644 node_modules/montage/core/url.js create mode 100755 node_modules/montage/core/uuid.js create mode 100755 node_modules/montage/data/blueprint.js create mode 100755 node_modules/montage/data/context.js create mode 100755 node_modules/montage/data/controllistener.js create mode 100755 node_modules/montage/data/ldapaccess/ldapblueprint.js create mode 100755 node_modules/montage/data/ldapaccess/ldapobjectid.js create mode 100755 node_modules/montage/data/ldapaccess/ldapselectorevaluator.js create mode 100755 node_modules/montage/data/ldapaccess/ldapstore.js create mode 100755 node_modules/montage/data/nosqlaccess/nosqlblueprint.js create mode 100755 node_modules/montage/data/nosqlaccess/nosqlobjectid.js create mode 100755 node_modules/montage/data/nosqlaccess/nosqlselectorevaluator.js create mode 100755 node_modules/montage/data/nosqlaccess/nosqlstore.js create mode 100755 node_modules/montage/data/objectid.js create mode 100755 node_modules/montage/data/objectproperty.js create mode 100755 node_modules/montage/data/pledge.js create mode 100755 node_modules/montage/data/query.js create mode 100755 node_modules/montage/data/restaccess/restblueprint.js create mode 100755 node_modules/montage/data/restaccess/restobjectid.js create mode 100755 node_modules/montage/data/restaccess/restselectorevaluator.js create mode 100755 node_modules/montage/data/restaccess/reststore.js create mode 100755 node_modules/montage/data/restriction.js create mode 100755 node_modules/montage/data/selector.js create mode 100755 node_modules/montage/data/sqlaccess/sqlblueprint.js create mode 100755 node_modules/montage/data/sqlaccess/sqlobjectid.js create mode 100755 node_modules/montage/data/sqlaccess/sqlselectorevaluator.js create mode 100755 node_modules/montage/data/sqlaccess/sqlstore.js create mode 100755 node_modules/montage/data/store.js create mode 100755 node_modules/montage/data/transactionid.js create mode 100755 node_modules/montage/effect/desaturate-effect.js create mode 100755 node_modules/montage/effect/effect.js create mode 100755 node_modules/montage/effect/invert-effect.js create mode 100755 node_modules/montage/effect/kaliedoscope-effect.js create mode 100755 node_modules/montage/effect/multiply-effect.js create mode 100755 node_modules/montage/effect/sepia-effect.js create mode 100755 node_modules/montage/montage.js create mode 100755 node_modules/montage/package.json create mode 100755 node_modules/montage/require/browser.js create mode 100755 node_modules/montage/require/require.js create mode 100755 node_modules/montage/service/service.js create mode 100755 node_modules/montage/ui/application.js create mode 100755 node_modules/montage/ui/button-group.reel/button-group.css create mode 100755 node_modules/montage/ui/button-group.reel/button-group.html create mode 100755 node_modules/montage/ui/button-group.reel/button-group.js create mode 100755 node_modules/montage/ui/button.reel/button.css create mode 100755 node_modules/montage/ui/button.reel/button.html create mode 100755 node_modules/montage/ui/button.reel/button.js create mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.css create mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.html create mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.js create mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark-disabled.svg create mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark.svg create mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-light-disabled.svg create mode 100755 node_modules/montage/ui/checkbox.reel/checkmark.svg create mode 100755 node_modules/montage/ui/component-group.reel/component-group.js create mode 100755 node_modules/montage/ui/component-placeholder.reel/component-placeholder.js create mode 100755 node_modules/montage/ui/component.js create mode 100755 node_modules/montage/ui/condition.reel/condition.js create mode 100755 node_modules/montage/ui/controller/array-controller.js create mode 100755 node_modules/montage/ui/controller/media-controller.js create mode 100755 node_modules/montage/ui/controller/object-controller.js create mode 100755 node_modules/montage/ui/controller/paged-array-controller.js create mode 100755 node_modules/montage/ui/dom.js create mode 100755 node_modules/montage/ui/dynamic-text.reel/dynamic-text.js create mode 100755 node_modules/montage/ui/editable-text.js create mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.html create mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.js create mode 100644 node_modules/montage/ui/flow-offset.js create mode 100644 node_modules/montage/ui/flow-path-cubic.js create mode 100644 node_modules/montage/ui/flow-path-lerp.js create mode 100644 node_modules/montage/ui/flow-path-linear.js create mode 100644 node_modules/montage/ui/flow-path-sigmoid.js create mode 100644 node_modules/montage/ui/flow-path.js create mode 100644 node_modules/montage/ui/flow.reel/flow.html create mode 100644 node_modules/montage/ui/flow.reel/flow.js create mode 100644 node_modules/montage/ui/hottext.reel/hottext.css create mode 100644 node_modules/montage/ui/hottext.reel/hottext.html create mode 100644 node_modules/montage/ui/hottext.reel/hottext.js create mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.css create mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.html create mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.js create mode 100644 node_modules/montage/ui/image.reel/image.js create mode 100644 node_modules/montage/ui/image2.reel/image2.html create mode 100644 node_modules/montage/ui/image2.reel/image2.js create mode 100644 node_modules/montage/ui/image3d.reel/image3d.html create mode 100644 node_modules/montage/ui/image3d.reel/image3d.js create mode 100755 node_modules/montage/ui/list.reel/list.html create mode 100755 node_modules/montage/ui/list.reel/list.js create mode 100755 node_modules/montage/ui/loader.reel/loader.js create mode 100755 node_modules/montage/ui/loading-panel.reel/loading-panel.css create mode 100755 node_modules/montage/ui/loading-panel.reel/loading-panel.html create mode 100755 node_modules/montage/ui/loading-panel.reel/loading-panel.js create mode 100755 node_modules/montage/ui/loading.reel/loading-0.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-1.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-2.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-3.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-4.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-5.svg create mode 100755 node_modules/montage/ui/loading.reel/loading-bg.svg create mode 100755 node_modules/montage/ui/loading.reel/loading.css create mode 100755 node_modules/montage/ui/loading.reel/loading.html create mode 100755 node_modules/montage/ui/loading.reel/loading.js create mode 100644 node_modules/montage/ui/nearest-neighbor-component-search.js create mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.css create mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.html create mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.js create mode 100755 node_modules/montage/ui/popup/alert.reel/alert.css create mode 100755 node_modules/montage/ui/popup/alert.reel/alert.html create mode 100755 node_modules/montage/ui/popup/alert.reel/alert.js create mode 100755 node_modules/montage/ui/popup/confirm.reel/confirm.css create mode 100755 node_modules/montage/ui/popup/confirm.reel/confirm.html create mode 100755 node_modules/montage/ui/popup/confirm.reel/confirm.js create mode 100755 node_modules/montage/ui/popup/notifier.reel/notifier.css create mode 100755 node_modules/montage/ui/popup/notifier.reel/notifier.html create mode 100755 node_modules/montage/ui/popup/notifier.reel/notifier.js create mode 100755 node_modules/montage/ui/popup/popup.reel/popup.css create mode 100755 node_modules/montage/ui/popup/popup.reel/popup.html create mode 100755 node_modules/montage/ui/popup/popup.reel/popup.js create mode 100755 node_modules/montage/ui/progress.reel/progress.css create mode 100755 node_modules/montage/ui/progress.reel/progress.html create mode 100755 node_modules/montage/ui/progress.reel/progress.js create mode 100755 node_modules/montage/ui/progress.reel/rule.png create mode 100755 node_modules/montage/ui/progress.reel/scroll.png create mode 100755 node_modules/montage/ui/repetition.reel/repetition.js create mode 100644 node_modules/montage/ui/scroll-bars.reel/scroll-bars.html create mode 100644 node_modules/montage/ui/scroll-bars.reel/scroll-bars.js create mode 100755 node_modules/montage/ui/scroll.js create mode 100644 node_modules/montage/ui/scroller.reel/scroller.html create mode 100644 node_modules/montage/ui/scroller.reel/scroller.js create mode 100755 node_modules/montage/ui/scrollview.reel/scrollview.js create mode 100644 node_modules/montage/ui/slider-base.js create mode 100755 node_modules/montage/ui/slider.reel/slider.css create mode 100755 node_modules/montage/ui/slider.reel/slider.html create mode 100755 node_modules/montage/ui/slider.reel/slider.js create mode 100755 node_modules/montage/ui/slot.reel/slot.js create mode 100755 node_modules/montage/ui/substitution.reel/substitution.js create mode 100755 node_modules/montage/ui/tabs.reel/tabs.css create mode 100755 node_modules/montage/ui/tabs.reel/tabs.html create mode 100755 node_modules/montage/ui/tabs.reel/tabs.js create mode 100755 node_modules/montage/ui/template.js create mode 100755 node_modules/montage/ui/textarea.reel/textarea.css create mode 100755 node_modules/montage/ui/textarea.reel/textarea.html create mode 100755 node_modules/montage/ui/textarea.reel/textarea.js create mode 100755 node_modules/montage/ui/textfield.reel/textfield.css create mode 100755 node_modules/montage/ui/textfield.reel/textfield.html create mode 100755 node_modules/montage/ui/textfield.reel/textfield.js create mode 100755 node_modules/montage/ui/toggle.reel/toggle.css create mode 100755 node_modules/montage/ui/toggle.reel/toggle.html create mode 100755 node_modules/montage/ui/toggle.reel/toggle.js create mode 100755 node_modules/montage/ui/video-player.reel/images/fullscreen-enter.png create mode 100755 node_modules/montage/ui/video-player.reel/images/fullscreen-exit.png create mode 100755 node_modules/montage/ui/video-player.reel/images/pause.png create mode 100755 node_modules/montage/ui/video-player.reel/images/play.png create mode 100755 node_modules/montage/ui/video-player.reel/images/volume-down.png create mode 100755 node_modules/montage/ui/video-player.reel/images/volume-up.png create mode 100755 node_modules/montage/ui/video-player.reel/video-player.css create mode 100755 node_modules/montage/ui/video-player.reel/video-player.html create mode 100755 node_modules/montage/ui/video-player.reel/video-player.js (limited to 'node_modules') diff --git a/node_modules/montage/core/bitfield.js b/node_modules/montage/core/bitfield.js new file mode 100755 index 00000000..2c274d3c --- /dev/null +++ b/node_modules/montage/core/bitfield.js @@ -0,0 +1,199 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/** + Defines the BitField class, that compactly stores multiple values as a short series of bits. + @module montage/core/bitfield + @requires montage/core/core + */ + +var Montage = require("montage").Montage; + + +/** + The BitField object compactly stores multiple values as a short series of bits. This implementation is limited to 32 fields. + @class module:montage/core/bitfield.BitField + @classdesc Compactly stores multiple values as a short series of bits. + @extends module:montage/core/core.Montage + */ +var BitField = exports.BitField = Montage.create(Montage, /** @lends module:montage/core/bitfield.BitField# */ { + + /** + Creates a new BitField object containing the fields provided in the propertyDescriptor parameter. + @function + @param {Object} propertyDescriptor An object containing one or more property name/value pairs. Each pair is added to the new BitField. + @returns {Object} A new BitField object that contains fields described by the property descriptor. + @example var bitField = BitField.create(); + bitField = BitField.create().initWithDescriptor({ + likes_golf: { + value: false + }, + likes_basketball: { + value: true + }, + likes_baseball: { + value: false + }, + }); + */ + initWithDescriptor: { + enumerable: false, + value: function(propertyDescriptor) { + var fieldName; + this.reset(); + for (fieldName in propertyDescriptor) { + this.addField(fieldName, propertyDescriptor[fieldName].value); + } + return this; + } + }, + + /** + Adds a new field to a BitField instance. + @function + @param {String} aFieldName The name of the field to add. + @param {Mixed} defaultValue The new field's default value. + */ + addField: { + enumerable: false, + value: function(aFieldName, defaultValue) { + if (aFieldName in this) { + return; + } + if (this._fieldCount >= 32) { + throw "BitField 32 fields limit reached."; + } + //We try to recycle slots as limited to 32bits + this._trueValue += (this._fields[aFieldName] = this._constantsToReuse.length ? this._constantsToReuse.shift() : (1 << this._fieldCount)); + Montage.defineProperty(this, aFieldName, { + enumerable: true, + get: function() { + return (this._value === this._trueValue); + }, + set: function(value) { + value ? (this._value |= this._fields[aFieldName]) : (this._value &= ~ (this._fields[aFieldName])); + if (this.value) { + this.callDelegateMethod(); + } + } + }); + this._fieldCount++; + if (!! defaultValue) { + this[aFieldName] = true; + } + } + }, + + /** + @private + */ + _constantsToReuse: { + enumerable: false, + value: [] + }, + + /** + Removes a field from the bitfield. + @function + @param {String} aFieldName The name of the field to remove. + */ + removeField: { + enumerable: false, + value: function(aFieldName) { + delete this[aFieldName]; + this._constantsToReuse.push(this._fields[aFieldName]); + this._trueValue -= this._fields[aFieldName]; + delete this._fields[aFieldName]; + } + }, + + /** + The BitField object's delegate. + @type {Property} + @default null + */ + delegate: { + enumerable: false, + value: null + }, + + /** + @function + @returns Nothing + */ + callDelegateMethod: { + value: function() { + var delegateMethod; + if (this.delegate && typeof (delegateMethod = this.delegate.bitFieldDidBecomeTrue) === "function") { + delegateMethod.call(this.delegate, this); + } + }, + enumerable: false + }, +/** + @type {Function} + @default {Number} 0 + */ + value: { + enumerable: false, + get: function() { + return (this._value === this._trueValue); + } + }, + + /** + @private + */ + _fieldCount: { + enumerable: false, + value: 0 + }, +/** + @private +*/ + _value: { + enumerable: false, + value: 0 + }, +/** + @private +*/ + _trueValue: { + enumerable: false, + value: 0 + }, +/** + @function + */ + reset: { + enumerable: false, + value: function() { + this._value = 0x0; + } + }, +/** + @private +*/ + _fields: { + enumerable: false, + value: {} + }, +/** + @function + @returns result + */ + toString: { + value: function() { + var fieldNames = this._fields, + i, + iField, + result = ""; + for (i = 0; (iField = fieldNames[i]); i++) { + result += iField + "[" + (this._value & fieldNames[iField]) + "], "; + } + return result; + } + } +}); diff --git a/node_modules/montage/core/converter/bytes-converter.js b/node_modules/montage/core/converter/bytes-converter.js new file mode 100755 index 00000000..1626f352 --- /dev/null +++ b/node_modules/montage/core/converter/bytes-converter.js @@ -0,0 +1,123 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/** + @module montage/core/converter/bytes-converter + @requires montage/core/core + @requires montage/core/converter/converter + @requires montage/core/converter/number-converter +*/ +var Montage = require("montage").Montage; +var Converter = require('core/converter/converter').Converter; +var _numericValueToString = require("core/converter/number-converter")._numericValueToString; +var _stringToNumericValue = require("core/converter/number-converter")._stringToNumericValue; +var NUMERIC_SCALES_BINARY_ = require("core/converter/number-converter").NUMERIC_SCALES_BINARY_; +var isDef = require('core/converter/converter').isDef; + +/** + @private +*/ +var NUMERIC_SCALE_PREFIXES_BYTES = [ + 'P', 'T', 'G', 'M', 'K', '', 'm', 'u', 'n' +]; + +/** + Converts a string to number of bytes, taking into account the units. + Binary conversion. + @function + @param {string} stringValue String to be converted to numeric value. + @return {number} Numeric value for string. + @private + */ +var stringToNumBytes = function(stringValue) { + return _stringToNumericValue(stringValue, NUMERIC_SCALES_BINARY_); +}; + +/** + Converts number of bytes to string representation. Binary conversion. + Default is to return the additional 'B' suffix, e.g. '10.5KB' to minimize confusion with counts that are scaled by powers of 1000. + @function + @param {Number} val Value to be converted. + @param {Number} opt_decimals The number of decimals to use. Defaults to 2. + @param {Boolean} opt_suffix If true, include trailing 'B' in returned string. Default is true. + @return {String} String representation of number of bytes. + @private + */ +var numBytesToString = function(val, opt_decimals, opt_suffix) { + var suffix = ''; + if (!isDef(opt_suffix) || opt_suffix) { + suffix = 'B'; + } + return _numericValueToString(val, NUMERIC_SCALES_BINARY_, opt_decimals, suffix, NUMERIC_SCALE_PREFIXES_BYTES); +}; + +/** + Formats a number of bytes in human readable form: 54, 450K, 1.3M, 5G etc. + @function + @param {Number} bytes The number of bytes to show. + @param {Number} opt_decimals The number of decimals to use. Defaults to 2. + @return {String} The human readable form of the byte size. + @private + */ +var fileSize = function(bytes, opt_decimals) { + return numBytesToString(bytes, opt_decimals, false); +}; + +/** + @class module:montage/core/converter/bytes-converter.BytesConverter + @classdesc Converts a numeric value to byte format (for example, 2048 is converted to 2MB). + @extends module:montage/core/converter.Converter + */ +exports.BytesConverter = Montage.create(Converter, /** @lends module:montage/core/converter/bytes-converter.BytesConverter# */ { + + /** + The number of decimals to include in the formatted value. Default is 2. + @type {Property} + @default {Number} 2 + */ + decimals: { + value: 2 + }, + /** + Converts the specified value to byte format. + @function + @param {Property} v The value to format. + @returns {String} The value converted to byte format. + @example + var Converter= require("core/converter/converter").Converter; + var BytesConverter = require("core/converter/converter").BytesConverter; + var bytes = "12341234"; + var byteconverter = BytesConverter.create(); + console.log("Converted: " + byteconverter.convert(bytes)); + console.log("Reverted: " + byteconverter.revert(bytes)); + // Converted: 11.77MB + // Reverted: 12341234 + */ + convert: { + value: function(v) { + return fileSize(v, this.decimals); + } + }, + /** + Reverts a formatted byte string to a standard number. + @function + @param {String} v The value to revert. + @returns {String} v + @see module:montage/converter.BytesConverter#convert + @example + var Converter= require("core/converter/converter").Converter; + var BytesConverter = require("core/converter/converter").BytesConverter; + var bytes = "11.77MB"; + var byteconverter = BytesConverter.create(); + console.log("Reverted: " + byteconverter.revert(bytes)); + // Reverted: 12341234 + */ + revert: { + value: function(v) { + return v; + } + } +}); + diff --git a/node_modules/montage/core/converter/converter.js b/node_modules/montage/core/converter/converter.js new file mode 100755 index 00000000..abce44e2 --- /dev/null +++ b/node_modules/montage/core/converter/converter.js @@ -0,0 +1,144 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/** + Provides common conversion, validation, and formatting functions for different types of values. + @module montage/core/converter/converter + @requires montage/core/core + */ +var Montage = require("montage").Montage; + + +var FUNCTION_CLASS = '[object Function]', + BOOLEAN_CLASS = '[object Boolean]', + NUMBER_CLASS = '[object Number]', + STRING_CLASS = '[object String]', + ARRAY_CLASS = '[object Array]', + DATE_CLASS = '[object Date]'; + +var _toString = Object.prototype.toString; + +// TODO should maybe move these into String.isString and Number.isNumber to parallel Array.isArray + +/** + @exports module:montage/core/converter#isString + @function +*/ +var isString = function(object) { + return _toString.call(object) === STRING_CLASS; +}; +exports.isString = isString; + +/** + @exports module:montage/core/converter#isNumber + @function +*/ +var isNumber = function(object) { + return _toString.call(object) === NUMBER_CLASS; +}; +exports.isNumber = isNumber; + + +/** + @exports module:montage/core/converter#isDef + @function +*/ +var isDef = function(obj) { + return (obj && typeof obj !== 'undefined'); +}; +exports.isDef = isDef; + + +var startsWith = exports.startsWith = function(str) { + return str.lastIndexOf(prefix, 0) === 0; +}; +var endsWith = exports.endsWith = function(str) { + var l = str.length - suffix.length; + return l >= 0 && str.indexOf(suffix, l) == l; +}; + +/** + Truncates a string to a certain length and adds '...' if necessary.
+ The length also accounts for the ellipsis, so a maximum length of 10 and a string
+ 'Hello World!' produces 'Hello W...'. + @function + @param {String} str The string to truncate. + @param {Number} chars Max number of characters. + @param {Boolean} opt_protectEscapedCharacters Whether to protect escaped characters from being cut off in the middle. + @return {String} The truncated {@code str} string. + */ +var truncate = exports.truncate = function(str, chars, opt_protectEscapedCharacters) { + if (opt_protectEscapedCharacters) { + goog.string.unescapeEntities(this); + } + + if (str.length > chars) { + return str.substring(0, chars - 3) + '…'; + } + + if (opt_protectEscapedCharacters) { + str.htmlEscape(this); + } + + return this; +}; + + +// Validators +/** + Base validator object. + @class module:montage/core/converter.Validator + @extends module:montage/core/core.Montage + */ +var Validator = exports.Validator = Montage.create(Montage, /** @lends module:montage/core/converter.Validator# */{ +/** + @type {Object} + @default null + */ + validate: { + value: null + } +}); + + +// Converters + +/** + @class module:montage/core/converter.Converter + @classdesc The base Converter class that is extended by specific converter classes. A Converter has two primary methods: + + */ +var Converter = exports.Converter = Montage.create(Montage, /** @lends module:montage/core/converter.Converter# */ { + + /** + Specifies whether the converter allows partial conversion. + @type {Property} + @default {Boolean} true + */ + allowPartialConversion: { + value: true + }, + + /** + @type {Property} + @default null + */ + convert: { + enumerable: false, + value: null + }, +/** + @type {Property} + @default null + */ + revert: { + enumerable: false, + value: null + } +}); + diff --git a/node_modules/montage/core/converter/currency-converter.js b/node_modules/montage/core/converter/currency-converter.js new file mode 100755 index 00000000..bba81dc1 --- /dev/null +++ b/node_modules/montage/core/converter/currency-converter.js @@ -0,0 +1,77 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/** + @module montage/core/converter/currency-converter + @requires montage/core/core + @requires montage/core/converter/converter + @requires montage/core/converter/number-converter +*/ +var Montage = require("montage").Montage; +var Converter = require('core/converter/converter'); +var numericValueToString = require("core/converter/number-converter").numericValueToString; +var NumberConverter = require("core/converter/number-converter").NumberConverter; +/** + Formats a number as a human-readable currency value. + @function module:montage/core/converter/currency-converter.#formatCurrency + @param {Property} value + @param {String} currency + @param {Number} decimals + @param {String} useParensForNegative + @returns stringValue +*/ +var formatCurrency = function(value, currency, decimals, useParensForNegative) { + var stringValue = numericValueToString(value, decimals); + currency = currency || '$'; + if ((value < 0) && useParensForNegative) { + stringValue = '(' + stringValue.substring(1, stringValue.length) + ')'; + } + + stringValue = stringValue + ' ' + currency; + return stringValue; +}; +/** + @class module:montage/core/converter/currency-converter.CurrencyConverter + @classdesc Formats a value as a currency. + @extends module:montage/core/converter/number-converter.NumberConverter + */ +exports.CurrencyConverter = Montage.create(NumberConverter, /** @lends module:montage/core/converter.CurrencyConverter# */ { + + /** + @type {Property} + @default {String} '$' + */ + currency: { + value: '$' + }, + + /** + @type {Property} + @default {Number} 2 + */ + decimals: { + value: 2 + }, + + /** + @type {Property} + @default {Boolean} false + */ + useParensForNegative: { + value: false + }, + + /** + @function + @param {String} v + @returns {string} The formatted currency value. + */ + convert: { + value: function(v) { + return formatCurrency(v, this.currency, this.decimals, this.useParensForNegative); + } + } + +}); diff --git a/node_modules/montage/core/converter/date-converter.js b/node_modules/montage/core/converter/date-converter.js new file mode 100755 index 00000000..b00a5b22 --- /dev/null +++ b/node_modules/montage/core/converter/date-converter.js @@ -0,0 +1,2621 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + /** + @version: 1.0 Alpha-1 + @author: Coolite Inc. http://www.coolite.com/ + @date: 2008-04-13 + @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. + @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. + @website: http://www.datejs.com/ + */ +/** + @module montage/core/converter/date-converter + @requires montage/core/core + @requires montage/core/converter/converter +*/ +var Montage = require("montage").Montage, + Converter = require("core/converter/converter").Converter, + Validator = require("core/converter/converter").Validator; + +(function () { + var $D = Date, + $P = $D.prototype, + $C = $D.CultureInfo, + p = function (s, l) { + if (!l) { + l = 2; + } + return ("000" + s).slice(l * -1); + }; + + /** + Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. + @function + @param {Boolean} .clone() this date instance before clearing Time + @return {Date} itself + */ + $P.clearTime = function () { + this.setHours(0); + this.setMinutes(0); + this.setSeconds(0); + this.setMilliseconds(0); + return this; + }; + + /** + * Resets the time of this Date object to the current time ('now'). + @function + @return {Date} itself + */ + $P.setTimeToNow = function () { + var n = new Date(); + this.setHours(n.getHours()); + this.setMinutes(n.getMinutes()); + this.setSeconds(n.getSeconds()); + this.setMilliseconds(n.getMilliseconds()); + return this; + }; + + /** + Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). + @function + @return {Date} The current date. + */ + $D.today = function () { + return new Date().clearTime(); + }; + + /** + Compares the first date to the second date and returns an number indication of their relative values. + @function + @param {Date} First Date object to compare [Required]. + @param {Date} Second Date object to compare to [Required]. + @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. + */ + $D.compare = function (date1, date2) { + if (isNaN(date1) || isNaN(date2)) { + throw new Error(date1 + " - " + date2); + } else if (date1 instanceof Date && date2 instanceof Date) { + return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; + } else { + throw new TypeError(date1 + " - " + date2); + } + }; + + /** + Compares the first Date object to the second Date object and returns true if they are equal. + @function + @param {Date} First Date object to compare [Required] + @param {Date} Second Date object to compare to [Required] + @return {Boolean} true if dates are equal. false if they are not equal. + */ + $D.equals = function (date1, date2) { + return (date1.compareTo(date2) === 0); + }; + + /** + Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). + @function + @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). + @return {Number} The day number + */ + $D.getDayNumberFromName = function (name) { + var n = $C.dayNames, m = $C.abbreviatedDayNames, o = $C.shortestDayNames, s = name.toLowerCase(); + for (var i = 0; i < n.length; i++) { + if (n[i].toLowerCase() == s || m[i].toLowerCase() == s || o[i].toLowerCase() == s) { + return i; + } + } + return -1; + }; + + /** + Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. + @function + @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). + @return {Number} The day number + */ + $D.getMonthNumberFromName = function (name) { + var n = $C.monthNames, m = $C.abbreviatedMonthNames, s = name.toLowerCase(); + for (var i = 0; i < n.length; i++) { + if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) { + return i; + } + } + return -1; + }; + + /** + Determines if the current date instance is within a LeapYear. + @function + @param {Number} The year. + @return {Boolean} true if date is within a LeapYear, otherwise false. + */ + $D.isLeapYear = function (year) { + return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); + }; + + /** + Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. + @function + @param {Number} The year. + @param {Number} The month (0-11). + @return {Number} The number of days in the month. + */ + $D.getDaysInMonth = function (year, month) { + return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; + }; + + /** + @function + @param {Number} offset + @returns null + */ + $D.getTimezoneAbbreviation = function (offset) { + var z = $C.timezones, p; + for (var i = 0; i < z.length; i++) { + if (z[i].offset === offset) { + return z[i].name; + } + } + return null; + }; + /** + @function + @param {String} name + @returns null + */ + $D.getTimezoneOffset = function (name) { + var z = $C.timezones, p; + for (var i = 0; i < z.length; i++) { + if (z[i].name === name.toUpperCase()) { + return z[i].offset; + } + } + return null; + }; + + /** + Returns a new Date object that is an exact date and time copy of the original instance. + @function + @return {Date} A new Date instance + */ + $P.clone = function () { + return new Date(this.getTime()); + }; + + /** + Compares this instance to a Date object and returns an number indication of their relative values. + @function + @param {Date} Date Object to compare [Required]. + @return {Number} -1 = This is less-than date. 0 = values are equal. 1 = this is greater-than date. + */ + $P.compareTo = function (date) { + return Date.compare(this, date); + }; + + /** + Compares this instance to another Date object and returns true if they are equal. + @function + @param {Date} Date Object to compare. If no date to compare, new Date() [now] is used. + @return {Boolean} true If dates are equal. False if they are not equal. + */ + $P.equals = function (date) { + return Date.equals(this, date || new Date()); + }; + + /** + Determines if this instance is between a range of two dates or equal to either the start or end dates. + @function + @param {Date} start Of range [Required] + @param {Date} end Of range [Required] + @return {Boolean} true This is between or equal to the start and end dates, else false. + */ + $P.between = function (start, end) { + return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); + }; + + /** + Determines if this date occurs after the date to compare to. + @function + @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. + @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. + */ + $P.isAfter = function (date) { + return this.compareTo(date || new Date()) === 1; + }; + + /** + Determines if this date occurs before the date to compare to. + @function + @param {Date} date object to compare. If no date to compare, new Date() ("now") is used. + @return {Boolean} true if this date instance is less than the date to compare to (or "now"). + */ + $P.isBefore = function (date) { + return (this.compareTo(date || new Date()) === -1); + }; + + /* + Determines if the current Date instance occurs today. + @function + @return {Boolean} true if this date instance is 'today', otherwise false. + */ + + /** + Determines if the current Date instance occurs on the same Date as the supplied 'date'. + If no 'date' to compare to is provided, the current Date instance is compared to 'today'. + @function + @param {Date} date object to compare. If no date to compare, the current Date ("now") is used. + @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. + */ + $P.isToday = $P.isSameDay = function (date) { + return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); + }; + + /** + Adds the specified number of milliseconds to this instance. + @function + @param {Number} value The number of milliseconds to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addMilliseconds = function (value) { + this.setMilliseconds(this.getMilliseconds() + value * 1); + return this; + }; + + /** + Adds the specified number of seconds to this instance. + @function + @param {Number} value The number of seconds to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addSeconds = function (value) { + return this.addMilliseconds(value * 1000); + }; + + /** + Adds the specified number of seconds to this instance. + @function + @param {Number} value The number of seconds to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addMinutes = function (value) { + return this.addMilliseconds(value * 60000); + /* 60*1000 */ + }; + + /** + Adds the specified number of hours to this instance. + @function + @param {Number} value The number of hours to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addHours = function (value) { + return this.addMilliseconds(value * 3600000); + /* 60*60*1000 */ + }; + + /** + Adds the specified number of days to this instance. + @function + @param {Number} value The number of days to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addDays = function (value) { + this.setDate(this.getDate() + value * 1); + return this; + }; + + /** + Adds the specified number of weeks to this instance. + @function + @param {Number} value The number of weeks to add. The number can be positive or negative [Required] + @return {Date} this.addDays(value * 7) + */ + $P.addWeeks = function (value) { + return this.addDays(value * 7); + }; + + /** + Adds the specified number of months to this instance. + @function + @param {Number} value The number of months to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addMonths = function (value) { + var n = this.getDate(); + this.setDate(1); + this.setMonth(this.getMonth() + value * 1); + this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); + return this; + }; + + /** + Adds the specified number of years to this instance. + @param {Number} value The number of years to add. The number can be positive or negative [Required] + @return {Date} this + */ + $P.addYears = function (value) { + return this.addMonths(value * 12); + }; + + /** + Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. + @function + @param {Object} config Configuration object containing attributes (months, days, etc.) + @return {Date} this + @example +

+         Date.today().add( { days: 1, months: 1 } )
+
+         new Date().add( { years: -1 } )
+        
+ */ + $P.add = function (config) { + if (typeof config == "number") { + this._orient = config; + return this; + } + + var x = config; + + if (x.milliseconds) { + this.addMilliseconds(x.milliseconds); + } + if (x.seconds) { + this.addSeconds(x.seconds); + } + if (x.minutes) { + this.addMinutes(x.minutes); + } + if (x.hours) { + this.addHours(x.hours); + } + if (x.weeks) { + this.addWeeks(x.weeks); + } + if (x.months) { + this.addMonths(x.months); + } + if (x.years) { + this.addYears(x.years); + } + if (x.days) { + this.addDays(x.days); + } + return this; + }; + + var $y, $m, $d; + + /** + Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. + This algorithm is a JavaScript port of the work presented by Claus Tøndering at http://www.tondering.dk/claus/cal/node8.html#SECTION00880000000000000000 + .getWeek() Algorithm Copyright (c) 2008 Claus Tondering. + The .getWeek() function does NOT convert the date to UTC. The local datetime is used. Please use .getISOWeek() to get the week of the UTC converted date. + @function + @return {Number} 1 to 53 + */ + $P.getWeek = function () { + var a, b, c, d, e, f, g, n, s, w; + + $y = (!$y) ? this.getFullYear() : $y; + $m = (!$m) ? this.getMonth() + 1 : $m; + $d = (!$d) ? this.getDate() : $d; + + if ($m <= 2) { + a = $y - 1; + b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); + c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); + s = b - c; + e = 0; + f = $d - 1 + (31 * ($m - 1)); + } else { + a = $y; + b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); + c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); + s = b - c; + e = s + 1; + f = $d + ((153 * ($m - 3) + 2) / 5) + 58 + s; + } + + g = (a + b) % 7; + d = (f + g - e) % 7; + n = (f + 3 - d) | 0; + + if (n < 0) { + w = 53 - ((g - s) / 5 | 0); + } else if (n > 364 + s) { + w = 1; + } else { + w = (n / 7 | 0) + 1; + } + + $y = $m = $d = null; + + return w; + }; + + /** + Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. + The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. + @function + @return {String} "01" to "53" + */ + $P.getISOWeek = function () { + $y = this.getUTCFullYear(); + $m = this.getUTCMonth() + 1; + $d = this.getUTCDate(); + return p(this.getWeek()); + }; + + /** + Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. + @function + @param {Number} n A Number (1 to 53) that represents the week of the year. + @return {Date} this + */ + $P.setWeek = function (n) { + return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek()); + }; + + // private +/** + @private +*/ + var validate = function (n, min, max, name) { + if (typeof n == "undefined") { + return false; + } else if (typeof n != "number") { + throw new TypeError(n + " is not a Number."); + } else if (n < min || n > max) { + throw new RangeError(n + " is not a valid value for " + name + "."); + } + return true; + }; + + /** + Validates the number is within an acceptable range for milliseconds [0-999]. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateMillisecond = function (value) { + return validate(value, 0, 999, "millisecond"); + }; + + /** + Validates the number is within an acceptable range for seconds [0-59]. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateSecond = function (value) { + return validate(value, 0, 59, "second"); + }; + + /** + Validates the number is within an acceptable range for minutes [0-59]. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateMinute = function (value) { + return validate(value, 0, 59, "minute"); + }; + + /** + Validates the number is within an acceptable range for hours [0-23]. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true If within range, otherwise false. + */ + $D.validateHour = function (value) { + return validate(value, 0, 23, "hour"); + }; + + /** + Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. + @function + @param {Number} value The number to check if within range. + @param {Number} year The number to check if within range. + @param {Number} month The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateDay = function (value, year, month) { + return validate(value, 1, $D.getDaysInMonth(year, month), "day"); + }; + + /** + Validates the number is within an acceptable range for months [0-11]. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateMonth = function (value) { + return validate(value, 0, 11, "month"); + }; + + /** + Validates the number is within an acceptable range for years. + @function + @param {Number} value The number to check if within range. + @return {Boolean} true if within range, otherwise false. + */ + $D.validateYear = function (value) { + return validate(value, 0, 9999, "year"); + }; + + /** + Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. + @function + @param {Object} config Configuration object containing attributes (month, day, etc.) + @return {Date} this + @example +

+        Date.today().set( { day: 20, month: 1 } )
+
+        new Date().set( { millisecond: 0 } )
+        
+ */ + $P.set = function (config) { + if ($D.validateMillisecond(config.millisecond)) { + this.addMilliseconds(config.millisecond - this.getMilliseconds()); + } + + if ($D.validateSecond(config.second)) { + this.addSeconds(config.second - this.getSeconds()); + } + + if ($D.validateMinute(config.minute)) { + this.addMinutes(config.minute - this.getMinutes()); + } + + if ($D.validateHour(config.hour)) { + this.addHours(config.hour - this.getHours()); + } + + if ($D.validateMonth(config.month)) { + this.addMonths(config.month - this.getMonth()); + } + + if ($D.validateYear(config.year)) { + this.addYears(config.year - this.getFullYear()); + } + + /* day has to go last because you can't validate the day without first knowing the month */ + if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) { + this.addDays(config.day - this.getDate()); + } + + if (config.timezone) { + this.setTimezone(config.timezone); + } + + if (config.timezoneOffset) { + this.setTimezoneOffset(config.timezoneOffset); + } + + if (config.week && validate(config.week, 0, 53, "week")) { + this.setWeek(config.week); + } + + return this; + }; + + /** + Moves the date to the first day of the month. + @function + @return {Date} this + */ + $P.moveToFirstDayOfMonth = function () { + return this.se