todo_rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/todo_rails/version.rb +1 -1
- data/vendor/assets/bower.json +8 -0
- data/vendor/assets/bower_components/angular-animate/README.md +68 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.js +3721 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.min.js +52 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.min.js.map +8 -0
- data/vendor/assets/bower_components/angular-animate/bower.json +9 -0
- data/vendor/assets/bower_components/angular-animate/index.js +2 -0
- data/vendor/assets/bower_components/angular-animate/package.json +26 -0
- data/vendor/assets/bower_components/angular-aria/README.md +67 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.js +393 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.min.js +13 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.min.js.map +8 -0
- data/vendor/assets/bower_components/angular-aria/bower.json +9 -0
- data/vendor/assets/bower_components/angular-aria/index.js +2 -0
- data/vendor/assets/bower_components/angular-aria/package.json +27 -0
- data/vendor/assets/bower_components/angular-material/CHANGELOG.md +1599 -0
- data/vendor/assets/bower_components/angular-material/LICENSE +21 -0
- data/vendor/assets/bower_components/angular-material/README.md +211 -0
- data/vendor/assets/bower_components/angular-material/angular-material-mocks.js +77 -0
- data/vendor/assets/bower_components/angular-material/angular-material.css +7183 -0
- data/vendor/assets/bower_components/angular-material/angular-material.js +15406 -0
- data/vendor/assets/bower_components/angular-material/angular-material.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/angular-material.min.js +14 -0
- data/vendor/assets/bower_components/angular-material/bower.json +14 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy2.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/facebook.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/hangout.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/mail.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/message.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/print.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/share-arrow.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/twitter.svg +2 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/upload.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/chips/demoBasicUsage/style.scss +39 -0
- data/vendor/assets/bower_components/angular-material/demos/chips/demoContactChips/style.scss +47 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoBasicUsage/style.scss +75 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoDynamicTiles/style.scss +78 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoResponsiveUsage/style.scss +0 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/addShoppingCart.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/core-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/social-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/addShoppingCart.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/core-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_email_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_person_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_phone_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_place_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/style.scss +18 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-0.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-1.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-2.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoDynamicHeight/style.scss +13 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoDynamicTabs/style.scss +44 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoStaticTabs/style.scss +25 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/favorite.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/menu.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/more_vert.svg +4 -0
- data/vendor/assets/bower_components/angular-material/index.js +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete.js +951 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop.css +59 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop.js +38 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button-default-theme.css +94 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button.css +158 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button.js +135 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card.css +34 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card.js +84 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox.css +124 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox.js +166 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips.css +131 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips.js +949 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content.js +84 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/core.css +2594 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/core.js +3772 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/default-theme.js +4 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog.js +713 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider.css +14 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider.js +45 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabActions/fabActions.js +57 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabSpeedDial/fabSpeedDial.css +100 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabSpeedDial/fabSpeedDial.js +236 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabToolbar/fabToolbar.css +74 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabToolbar/fabToolbar.js +218 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabTrigger/fabTrigger.js +54 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList-default-theme.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList.css +68 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList.js +762 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon-default-theme.css +15 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon.js +783 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input-default-theme.css +46 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input.css +162 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input.js +371 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list-default-theme.css +23 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list.css +147 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list.js +273 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu.css +121 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu.js +620 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular-default-theme.css +36 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular.css +1409 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular.js +109 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear-default-theme.css +27 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear.css +287 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear.js +126 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton.css +91 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton.js +312 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select-default-theme.css +42 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select.js +1055 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav.css +99 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav.js +424 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider-default-theme.css +56 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider.js +403 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sticky/sticky.css +21 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sticky/sticky.js +315 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader.css +63 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader.js +93 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/swipe/swipe.js +72 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch-default-theme.css +33 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch.css +110 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs-arrow.svg +7 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs-default-theme.css +82 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs.css +274 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs.js +1060 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField-default-theme.css +30 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField.js +145 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast-default-theme.css +18 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast.css +119 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast.js +265 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar-default-theme.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar.css +83 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip.css +72 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/whiteframe/whiteframe.css +25 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/whiteframe/whiteframe.js +15 -0
- data/vendor/assets/bower_components/angular-material/modules/css/angular-material-layout.css +2375 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.js +951 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.css +59 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.js +39 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button-default-theme.css +94 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.css +158 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.js +136 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.css +34 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.js +85 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.css +124 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.js +167 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.css +131 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.js +949 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.js +85 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.css +2594 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.js +3772 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.min.js +10 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/default-theme.js +4 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.js +713 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.css +14 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.js +46 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/fabActions.js +58 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/fabActions.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/bower.json +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.css +100 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.js +235 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/bower.json +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.css +74 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.js +217 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/fabTrigger.js +55 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/fabTrigger.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.css +68 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.js +763 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon-default-theme.css +15 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.js +784 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input-default-theme.css +46 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.css +162 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.js +372 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list-default-theme.css +23 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.css +147 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.js +274 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.css +121 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.js +620 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.css +36 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.css +1409 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.js +110 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.css +27 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.css +287 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.js +127 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.css +91 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.js +313 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select-default-theme.css +42 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.js +1055 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.css +99 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.js +424 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider-default-theme.css +56 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.js +404 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.css +21 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.js +315 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.css +63 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.js +93 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/swipe.js +73 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/swipe.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch-default-theme.css +33 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.css +110 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs-default-theme.css +82 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.css +274 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.js +1060 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField-default-theme.css +30 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.js +143 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast-default-theme.css +18 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.css +119 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.js +265 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.css +83 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.css +72 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.js +268 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/bower.json +5 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.css +25 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.js +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/package.json +48 -0
- data/vendor/assets/bower_components/angular/README.md +64 -0
- data/vendor/assets/bower_components/angular/angular-csp.css +21 -0
- data/vendor/assets/bower_components/angular/angular.js +28364 -0
- data/vendor/assets/bower_components/angular/angular.min.js +290 -0
- data/vendor/assets/bower_components/angular/angular.min.js.gzip +0 -0
- data/vendor/assets/bower_components/angular/angular.min.js.map +8 -0
- data/vendor/assets/bower_components/angular/bower.json +8 -0
- data/vendor/assets/bower_components/angular/index.js +2 -0
- data/vendor/assets/bower_components/angular/package.json +25 -0
- data/vendor/assets/bower_components/lodash/LICENSE +22 -0
- data/vendor/assets/bower_components/lodash/bower.json +19 -0
- data/vendor/assets/bower_components/lodash/lodash.js +12351 -0
- data/vendor/assets/bower_components/lodash/lodash.min.js +99 -0
- data/vendor/assets/bower_components/restangular/CHANGELOG.md +18 -0
- data/vendor/assets/bower_components/restangular/CONTRIBUTE.md +31 -0
- data/vendor/assets/bower_components/restangular/Gruntfile.js +149 -0
- data/vendor/assets/bower_components/restangular/README.md +1336 -0
- data/vendor/assets/bower_components/restangular/bower.json +19 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.js +1355 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.min.js +6 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.zip +0 -0
- data/vendor/assets/bower_components/restangular/karma.conf.js +74 -0
- data/vendor/assets/bower_components/restangular/karma.underscore.conf.js +74 -0
- data/vendor/assets/bower_components/restangular/license.md +21 -0
- data/vendor/assets/bower_components/restangular/package.json +55 -0
- data/vendor/assets/bower_components/restangular/src/restangular.js +1350 -0
- data/vendor/assets/bower_components/restangular/test/restangularSpec.js +1136 -0
- metadata +424 -1
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* Restful Resources service for AngularJS apps
|
3
|
+
* @version v1.4.0 - 2015-04-03 * @link https://github.com/mgonto/restangular
|
4
|
+
* @author Martin Gontovnikas <martin@gon.to>
|
5
|
+
* @license MIT License, http://www.opensource.org/licenses/MIT
|
6
|
+
*/!function(){var a=angular.module("restangular",[]);a.provider("Restangular",function(){var a={};a.init=function(a,b){function c(a,b,c,d){var e={};return _.each(_.keys(d),function(f){var g=d[f];g.params=_.extend({},g.params,a.defaultRequestParams[g.method.toLowerCase()]),_.isEmpty(g.params)&&delete g.params,e[f]=a.isSafe(g.method)?function(){return b(_.extend(g,{url:c}))}:function(a){return b(_.extend(g,{url:c,data:a}))}}),e}a.configuration=b;var d=["get","head","options","trace","getlist"];b.isSafe=function(a){return _.contains(d,a.toLowerCase())};var e=/^https?:\/\//i;b.isAbsoluteUrl=function(a){return _.isUndefined(b.absoluteUrl)||_.isNull(b.absoluteUrl)?a&&e.test(a):b.absoluteUrl},b.absoluteUrl=_.isUndefined(b.absoluteUrl)?!0:b.absoluteUrl,a.setSelfLinkAbsoluteUrl=function(a){b.absoluteUrl=a},b.baseUrl=_.isUndefined(b.baseUrl)?"":b.baseUrl,a.setBaseUrl=function(a){return b.baseUrl=/\/$/.test(a)?a.substring(0,a.length-1):a,this},b.extraFields=b.extraFields||[],a.setExtraFields=function(a){return b.extraFields=a,this},b.defaultHttpFields=b.defaultHttpFields||{},a.setDefaultHttpFields=function(a){return b.defaultHttpFields=a,this},b.withHttpValues=function(a,c){return _.defaults(c,a,b.defaultHttpFields)},b.encodeIds=_.isUndefined(b.encodeIds)?!0:b.encodeIds,a.setEncodeIds=function(a){b.encodeIds=a},b.defaultRequestParams=b.defaultRequestParams||{get:{},post:{},put:{},remove:{},common:{}},a.setDefaultRequestParams=function(a,c){var d=[],e=c||a;return _.isUndefined(c)?d.push("common"):_.isArray(a)?d=a:d.push(a),_.each(d,function(a){b.defaultRequestParams[a]=e}),this},a.requestParams=b.defaultRequestParams,b.defaultHeaders=b.defaultHeaders||{},a.setDefaultHeaders=function(c){return b.defaultHeaders=c,a.defaultHeaders=b.defaultHeaders,this},a.defaultHeaders=b.defaultHeaders,b.methodOverriders=b.methodOverriders||[],a.setMethodOverriders=function(a){var c=_.extend([],a);return b.isOverridenMethod("delete",c)&&c.push("remove"),b.methodOverriders=c,this},b.jsonp=_.isUndefined(b.jsonp)?!1:b.jsonp,a.setJsonp=function(a){b.jsonp=a},b.isOverridenMethod=function(a,c){var d=c||b.methodOverriders;return!_.isUndefined(_.find(d,function(b){return b.toLowerCase()===a.toLowerCase()}))},b.urlCreator=b.urlCreator||"path",a.setUrlCreator=function(a){if(!_.has(b.urlCreatorFactory,a))throw new Error("URL Path selected isn't valid");return b.urlCreator=a,this},b.restangularFields=b.restangularFields||{id:"id",route:"route",parentResource:"parentResource",restangularCollection:"restangularCollection",cannonicalId:"__cannonicalId",etag:"restangularEtag",selfLink:"href",get:"get",getList:"getList",put:"put",post:"post",remove:"remove",head:"head",trace:"trace",options:"options",patch:"patch",getRestangularUrl:"getRestangularUrl",getRequestedUrl:"getRequestedUrl",putElement:"putElement",addRestangularMethod:"addRestangularMethod",getParentList:"getParentList",clone:"clone",ids:"ids",httpConfig:"_$httpConfig",reqParams:"reqParams",one:"one",all:"all",several:"several",oneUrl:"oneUrl",allUrl:"allUrl",customPUT:"customPUT",customPOST:"customPOST",customDELETE:"customDELETE",customGET:"customGET",customGETLIST:"customGETLIST",customOperation:"customOperation",doPUT:"doPUT",doPOST:"doPOST",doDELETE:"doDELETE",doGET:"doGET",doGETLIST:"doGETLIST",fromServer:"fromServer",withConfig:"withConfig",withHttpConfig:"withHttpConfig",singleOne:"singleOne",plain:"plain",save:"save",restangularized:"restangularized"},a.setRestangularFields=function(a){return b.restangularFields=_.extend(b.restangularFields,a),this},b.isRestangularized=function(a){return!!a[b.restangularFields.restangularized]},b.setFieldToElem=function(a,b,c){var d=a.split("."),e=b;return _.each(_.initial(d),function(a){e[a]={},e=e[a]}),e[_.last(d)]=c,this},b.getFieldFromElem=function(a,b){var c=a.split("."),d=b;return _.each(c,function(a){d&&(d=d[a])}),angular.copy(d)},b.setIdToElem=function(a,c){return b.setFieldToElem(b.restangularFields.id,a,c),this},b.getIdFromElem=function(a){return b.getFieldFromElem(b.restangularFields.id,a)},b.isValidId=function(a){return""!==a&&!_.isUndefined(a)&&!_.isNull(a)},b.setUrlToElem=function(a,c){return b.setFieldToElem(b.restangularFields.selfLink,a,c),this},b.getUrlFromElem=function(a){return b.getFieldFromElem(b.restangularFields.selfLink,a)},b.useCannonicalId=_.isUndefined(b.useCannonicalId)?!1:b.useCannonicalId,a.setUseCannonicalId=function(a){return b.useCannonicalId=a,this},b.getCannonicalIdFromElem=function(a){var c=a[b.restangularFields.cannonicalId],d=b.isValidId(c)?c:b.getIdFromElem(a);return d},b.responseInterceptors=b.responseInterceptors||[],b.defaultResponseInterceptor=function(a){return a},b.responseExtractor=function(a,c,d,e,f,g){var h=angular.copy(b.responseInterceptors);h.push(b.defaultResponseInterceptor);var i=a;return _.each(h,function(a){i=a(i,c,d,e,f,g)}),i},a.addResponseInterceptor=function(a){return b.responseInterceptors.push(a),this},b.errorInterceptors=b.errorInterceptors||[],a.addErrorInterceptor=function(a){return b.errorInterceptors.push(a),this},a.setResponseInterceptor=a.addResponseInterceptor,a.setResponseExtractor=a.addResponseInterceptor,a.setErrorInterceptor=a.addErrorInterceptor,b.requestInterceptors=b.requestInterceptors||[],b.defaultInterceptor=function(a,b,c,d,e,f,g){return{element:a,headers:e,params:f,httpConfig:g}},b.fullRequestInterceptor=function(a,c,d,e,f,g,h){var i=angular.copy(b.requestInterceptors),j=b.defaultInterceptor(a,c,d,e,f,g,h);return _.reduce(i,function(a,b){return _.extend(a,b(a.element,c,d,e,a.headers,a.params,a.httpConfig))},j)},a.addRequestInterceptor=function(a){return b.requestInterceptors.push(function(b,c,d,e,f,g,h){return{headers:f,params:g,element:a(b,c,d,e),httpConfig:h}}),this},a.setRequestInterceptor=a.addRequestInterceptor,a.addFullRequestInterceptor=function(a){return b.requestInterceptors.push(a),this},a.setFullRequestInterceptor=a.addFullRequestInterceptor,b.onBeforeElemRestangularized=b.onBeforeElemRestangularized||function(a){return a},a.setOnBeforeElemRestangularized=function(a){return b.onBeforeElemRestangularized=a,this},a.setRestangularizePromiseInterceptor=function(a){return b.restangularizePromiseInterceptor=a,this},b.onElemRestangularized=b.onElemRestangularized||function(a){return a},a.setOnElemRestangularized=function(a){return b.onElemRestangularized=a,this},b.shouldSaveParent=b.shouldSaveParent||function(){return!0},a.setParentless=function(a){return _.isArray(a)?b.shouldSaveParent=function(b){return!_.contains(a,b)}:_.isBoolean(a)&&(b.shouldSaveParent=function(){return!a}),this},b.suffix=_.isUndefined(b.suffix)?null:b.suffix,a.setRequestSuffix=function(a){return b.suffix=a,this},b.transformers=b.transformers||{},a.addElementTransformer=function(c,d,e){var f=null,g=null;2===arguments.length?g=d:(g=e,f=d);var h=b.transformers[c];return h||(h=b.transformers[c]=[]),h.push(function(a,b){return _.isNull(f)||a===f?g(b):b}),a},a.extendCollection=function(b,c){return a.addElementTransformer(b,!0,c)},a.extendModel=function(b,c){return a.addElementTransformer(b,!1,c)},b.transformElem=function(a,c,d,e,f){if(!f&&!b.transformLocalElements&&!a[b.restangularFields.fromServer])return a;var g=b.transformers[d],h=a;return g&&_.each(g,function(a){h=a(c,h)}),b.onElemRestangularized(h,c,d,e)},b.transformLocalElements=_.isUndefined(b.transformLocalElements)?!1:b.transformLocalElements,a.setTransformOnlyServerElements=function(a){b.transformLocalElements=!a},b.fullResponse=_.isUndefined(b.fullResponse)?!1:b.fullResponse,a.setFullResponse=function(a){return b.fullResponse=a,this},b.urlCreatorFactory={};var f=function(){};f.prototype.setConfig=function(a){return this.config=a,this},f.prototype.parentsArray=function(a){for(var b=[];a;)b.push(a),a=a[this.config.restangularFields.parentResource];return b.reverse()},f.prototype.resource=function(a,d,e,f,g,h,i,j){var k=_.defaults(g||{},this.config.defaultRequestParams.common),l=_.defaults(f||{},this.config.defaultHeaders);i&&(b.isSafe(j)?l["If-None-Match"]=i:l["If-Match"]=i);var m=this.base(a);if(h){var n="";/\/$/.test(m)||(n+="/"),n+=h,m+=n}return this.config.suffix&&-1===m.indexOf(this.config.suffix,m.length-this.config.suffix.length)&&!this.config.getUrlFromElem(a)&&(m+=this.config.suffix),a[this.config.restangularFields.httpConfig]=void 0,c(this.config,d,m,{getList:this.config.withHttpValues(e,{method:"GET",params:k,headers:l}),get:this.config.withHttpValues(e,{method:"GET",params:k,headers:l}),jsonp:this.config.withHttpValues(e,{method:"jsonp",params:k,headers:l}),put:this.config.withHttpValues(e,{method:"PUT",params:k,headers:l}),post:this.config.withHttpValues(e,{method:"POST",params:k,headers:l}),remove:this.config.withHttpValues(e,{method:"DELETE",params:k,headers:l}),head:this.config.withHttpValues(e,{method:"HEAD",params:k,headers:l}),trace:this.config.withHttpValues(e,{method:"TRACE",params:k,headers:l}),options:this.config.withHttpValues(e,{method:"OPTIONS",params:k,headers:l}),patch:this.config.withHttpValues(e,{method:"PATCH",params:k,headers:l})})};var g=function(){};g.prototype=new f,g.prototype.normalizeUrl=function(a){var b=/(http[s]?:\/\/)?(.*)?/.exec(a);return b[2]=b[2].replace(/[\\\/]+/g,"/"),"undefined"!=typeof b[1]?b[1]+b[2]:b[2]},g.prototype.base=function(a){var c=this;return _.reduce(this.parentsArray(a),function(a,d){var e,f=c.config.getUrlFromElem(d);if(f){if(c.config.isAbsoluteUrl(f))return f;e=f}else if(e=d[c.config.restangularFields.route],d[c.config.restangularFields.restangularCollection]){var g=d[c.config.restangularFields.ids];g&&(e+="/"+g.join(","))}else{var h;h=c.config.useCannonicalId?c.config.getCannonicalIdFromElem(d):c.config.getIdFromElem(d),b.isValidId(h)&&!d.singleOne&&(e+="/"+(c.config.encodeIds?encodeURIComponent(h):h))}return a=a.replace(/\/$/,"")+"/"+e,c.normalizeUrl(a)},this.config.baseUrl)},g.prototype.fetchUrl=function(a,b){var c=this.base(a);return b&&(c+="/"+b),c},g.prototype.fetchRequestedUrl=function(a,c){function d(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b.sort()}function e(a,b,c){for(var e=d(a),f=0;f<e.length;f++)b.call(c,a[e[f]],e[f]);return e}function f(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,b?"%20":"+")}var g=this.fetchUrl(a,c),h=a[b.restangularFields.reqParams];if(!h)return g+(this.config.suffix||"");var i=[];return e(h,function(a,b){null!==a&&void 0!==a&&(angular.isArray(a)||(a=[a]),angular.forEach(a,function(a){angular.isObject(a)&&(a=angular.toJson(a)),i.push(f(b)+"="+f(a))}))}),g+(this.config.suffix||"")+(-1===g.indexOf("?")?"?":"&")+i.join("&")},b.urlCreatorFactory.path=g};var b={};a.init(this,b),this.$get=["$http","$q",function(c,d){function e(b){function f(a,c,d,e,f){if(c[b.restangularFields.route]=d,c[b.restangularFields.getRestangularUrl]=_.bind(P.fetchUrl,P,c),c[b.restangularFields.getRequestedUrl]=_.bind(P.fetchRequestedUrl,P,c),c[b.restangularFields.addRestangularMethod]=_.bind(L,c),c[b.restangularFields.clone]=_.bind(r,c,c),c[b.restangularFields.reqParams]=_.isEmpty(e)?null:e,c[b.restangularFields.withHttpConfig]=_.bind(z,c),c[b.restangularFields.plain]=_.bind(p,c,c),c[b.restangularFields.restangularized]=!0,c[b.restangularFields.one]=_.bind(g,c,c),c[b.restangularFields.all]=_.bind(h,c,c),c[b.restangularFields.several]=_.bind(i,c,c),c[b.restangularFields.oneUrl]=_.bind(j,c,c),c[b.restangularFields.allUrl]=_.bind(k,c,c),c[b.restangularFields.fromServer]=!!f,a&&b.shouldSaveParent(d)){var l=b.getIdFromElem(a),m=b.getUrlFromElem(a),n=_.union(_.values(_.pick(b.restangularFields,["route","singleOne","parentResource"])),b.extraFields),o=_.pick(a,n);b.isValidId(l)&&b.setIdToElem(o,l,d),b.isValidId(m)&&b.setUrlToElem(o,m,d),c[b.restangularFields.parentResource]=o}else c[b.restangularFields.parentResource]=null;return c}function g(a,c,d,e){var f;if(_.isNumber(c)||_.isNumber(a))throw f="You're creating a Restangular entity with the number ",f+="instead of the route or the parent. For example, you can't call .one(12).",new Error(f);if(_.isUndefined(c))throw f="You're creating a Restangular entity either without the path. ",f+="For example you can't call .one(). Please check if your arguments are valid.",new Error(f);var g={};return b.setIdToElem(g,d,c),b.setFieldToElem(b.restangularFields.singleOne,g,e),s(a,g,c,!1)}function h(a,b){return t(a,[],b,!1)}function i(a,c){var d=[];return d[b.restangularFields.ids]=Array.prototype.splice.call(arguments,2),t(a,d,c,!1)}function j(a,c,d){if(!c)throw new Error("Route is mandatory when creating new Restangular objects.");var e={};return b.setUrlToElem(e,d,c),s(a,e,c,!1)}function k(a,c,d){if(!c)throw new Error("Route is mandatory when creating new Restangular objects.");var e={};return b.setUrlToElem(e,d,c),t(a,e,c,!1)}function l(a,c,d){return a.call=_.bind(m,a),a.get=_.bind(n,a),a[b.restangularFields.restangularCollection]=c,c&&(a.push=_.bind(m,a,"push")),a.$object=d,b.restangularizePromiseInterceptor&&b.restangularizePromiseInterceptor(a),a}function m(a){var c=d.defer(),e=arguments,f={};return this.then(function(b){var d=Array.prototype.slice.call(e,1),g=b[a];g.apply(b,d),f=b,c.resolve(b)}),l(c.promise,this[b.restangularFields.restangularCollection],f)}function n(a){var c=d.defer(),e={};return this.then(function(b){e=b[a],c.resolve(e)}),l(c.promise,this[b.restangularFields.restangularCollection],e)}function o(a,c,d,e){return _.extend(e,d),b.fullResponse?a.resolve(_.extend(c,{data:d})):(a.resolve(d),void 0)}function p(a){if(_.isArray(a)){var c=[];return _.each(a,function(a){c.push(b.isRestangularized(a)?p(a):a)}),c}return _.omit(a,_.values(_.omit(b.restangularFields,"id")))}function q(a){a[b.restangularFields.customOperation]=_.bind(K,a),_.each(["put","post","get","delete"],function(b){_.each(["do","custom"],function(c){var d,e="delete"===b?"remove":b,f=c+b.toUpperCase();d="put"!==e&&"post"!==e?K:function(a,b,c,d,e){return _.bind(K,this)(a,c,d,e,b)},a[f]=_.bind(d,a,e)})}),a[b.restangularFields.customGETLIST]=_.bind(y,a),a[b.restangularFields.doGETLIST]=a[b.restangularFields.customGETLIST]}function r(a,c){var d=angular.copy(a,c);return s(d[b.restangularFields.parentResource],d,d[b.restangularFields.route],!0)}function s(a,c,d,e,g,h){var i=b.onBeforeElemRestangularized(c,!1,d),j=f(a,i,d,h,e);return b.useCannonicalId&&(j[b.restangularFields.cannonicalId]=b.getIdFromElem(j)),g&&(j[b.restangularFields.getParentList]=function(){return g}),j[b.restangularFields.restangularCollection]=!1,j[b.restangularFields.get]=_.bind(C,j),j[b.restangularFields.getList]=_.bind(y,j),j[b.restangularFields.put]=_.bind(E,j),j[b.restangularFields.post]=_.bind(F,j),j[b.restangularFields.remove]=_.bind(D,j),j[b.restangularFields.head]=_.bind(G,j),j[b.restangularFields.trace]=_.bind(H,j),j[b.restangularFields.options]=_.bind(I,j),j[b.restangularFields.patch]=_.bind(J,j),j[b.restangularFields.save]=_.bind(A,j),q(j),b.transformElem(j,!1,d,O,!0)}function t(a,c,d,e,g){var h=b.onBeforeElemRestangularized(c,!0,d),i=f(a,h,d,g,e);return i[b.restangularFields.restangularCollection]=!0,i[b.restangularFields.post]=_.bind(F,i,null),i[b.restangularFields.remove]=_.bind(D,i),i[b.restangularFields.head]=_.bind(G,i),i[b.restangularFields.trace]=_.bind(H,i),i[b.restangularFields.putElement]=_.bind(w,i),i[b.restangularFields.options]=_.bind(I,i),i[b.restangularFields.patch]=_.bind(J,i),i[b.restangularFields.get]=_.bind(v,i),i[b.restangularFields.getList]=_.bind(y,i,null),q(i),b.transformElem(i,!0,d,O,!0)}function u(a,b,c){var d=t(a,b,c,!1);return _.each(d,function(b){s(a,b,c,!1)}),d}function v(a,b,c){return this.customGET(a.toString(),b,c)}function w(a,c,e){var f=this,g=this[a],h=d.defer(),i=[];return i=b.transformElem(i,!0,g[b.restangularFields.route],O),g.put(c,e).then(function(b){var c=r(f);c[a]=b,i=c,h.resolve(c)},function(a){h.reject(a)}),l(h.promise,!0,i)}function x(a,c,d,e,f,g){var h=b.responseExtractor(a,c,d,e,f,g),i=f.headers("ETag");return h&&i&&(h[b.restangularFields.etag]=i),h}function y(a,e,f){var g=this,h=d.defer(),i="getList",j=P.fetchUrl(this,a),k=a||g[b.restangularFields.route],m=b.fullRequestInterceptor(null,i,k,j,f||{},e||{},this[b.restangularFields.httpConfig]||{}),n=[];n=b.transformElem(n,!0,k,O);var p="getList";b.jsonp&&(p="jsonp");var q=function(c){var d=c.data,e=c.config.params,f=x(d,i,k,j,c,h);if((_.isUndefined(f)||""===f)&&(f=[]),!_.isArray(f))throw new Error("Response for getList SHOULD be an array and not an object or something else");var l=_.map(f,function(c){return g[b.restangularFields.restangularCollection]?s(g[b.restangularFields.parentResource],c,g[b.restangularFields.route],!0,f):s(g,c,a,!0,f)});l=_.extend(f,l),g[b.restangularFields.restangularCollection]?o(h,c,t(g[b.restangularFields.parentResource],l,g[b.restangularFields.route],!0,e),n):o(h,c,t(g,l,a,!0,e),n)};return P.resource(this,c,m.httpConfig,m.headers,m.params,a,this[b.restangularFields.etag],i)[p]().then(q,function(a){304===a.status&&g[b.restangularFields.restangularCollection]?o(h,a,g,n):_.every(b.errorInterceptors,function(b){return b(a,h,q)!==!1})&&h.reject(a)}),l(h.promise,!0,n)}function z(a){return this[b.restangularFields.httpConfig]=a,this}function A(a,c){return this[b.restangularFields.fromServer]?this[b.restangularFields.put](a,c):_.bind(B,this)("post",void 0,a,void 0,c)}function B(a,e,f,g,h){var i=this,j=d.defer(),k=f||{},m=e||this[b.restangularFields.route],n=P.fetchUrl(this,e),q=g||this,r=q[b.restangularFields.etag]||("post"!==a?this[b.restangularFields.etag]:null);_.isObject(q)&&b.isRestangularized(q)&&(q=p(q));var t=b.fullRequestInterceptor(q,a,m,n,h||{},k||{},this[b.restangularFields.httpConfig]||{}),u={};u=b.transformElem(u,!1,m,O);var v=function(c){var d=c.data,e=c.config.params,f=x(d,a,m,n,c,j);if(f)if("post"!==a||i[b.restangularFields.restangularCollection]){var g=s(i[b.restangularFields.parentResource],f,i[b.restangularFields.route],!0,null,e);g[b.restangularFields.singleOne]=i[b.restangularFields.singleOne],o(j,c,g,u)}else{var g=s(i[b.restangularFields.parentResource],f,m,!0,null,e);o(j,c,g,u)}else o(j,c,void 0,u)},w=function(c){304===c.status&&b.isSafe(a)?o(j,c,i,u):_.every(b.errorInterceptors,function(a){return a(c,j,v)!==!1})&&j.reject(c)},y=a,z=_.extend({},t.headers),A=b.isOverridenMethod(a);return A?(y="post",z=_.extend(z,{"X-HTTP-Method-Override":"remove"===a?"DELETE":a.toUpperCase()})):b.jsonp&&"get"===y&&(y="jsonp"),b.isSafe(a)?A?P.resource(this,c,t.httpConfig,z,t.params,e,r,y)[y]({}).then(v,w):P.resource(this,c,t.httpConfig,z,t.params,e,r,y)[y]().then(v,w):P.resource(this,c,t.httpConfig,z,t.params,e,r,y)[y](t.element).then(v,w),l(j.promise,!1,u)}function C(a,b){return _.bind(B,this)("get",void 0,a,void 0,b)}function D(a,b){return _.bind(B,this)("remove",void 0,a,void 0,b)}function E(a,b){return _.bind(B,this)("put",void 0,a,void 0,b)}function F(a,b,c,d){return _.bind(B,this)("post",a,c,b,d)}function G(a,b){return _.bind(B,this)("head",void 0,a,void 0,b)}function H(a,b){return _.bind(B,this)("trace",void 0,a,void 0,b)}function I(a,b){return _.bind(B,this)("options",void 0,a,void 0,b)}function J(a,b,c){return _.bind(B,this)("patch",void 0,b,a,c)}function K(a,b,c,d,e){return _.bind(B,this)(a,b,c,e,d)}function L(a,c,d,e,f,g){var h;h="getList"===c?_.bind(y,this,d):_.bind(K,this,c,d);var i=function(a,b,c){var d=_.defaults({params:a,headers:b,elem:c},{params:e,headers:f,elem:g});return h(d.params,d.headers,d.elem)};this[a]=b.isSafe(c)?i:function(a,b,c){return i(b,c,a)}}function M(c){var d=angular.copy(_.omit(b,"configuration"));return a.init(d,d),c(d),e(d)}function N(a,c){var d=_.values(b.restangularFields),e={},f=(c||O).all(a);e.one=_.bind(g,c||O,c,a),e.post=_.bind(f.post,f),e.getList=_.bind(f.getList,f);for(var h in f)f.hasOwnProperty(h)&&_.isFunction(f[h])&&!_.contains(d,h)&&(e[h]=_.bind(f[h],f));return e}var O={},P=new b.urlCreatorFactory[b.urlCreator];return P.setConfig(b),a.init(O,b),O.copy=_.bind(r,O),O.service=_.bind(N,O),O.withConfig=_.bind(M,O),O.one=_.bind(g,O,null),O.all=_.bind(h,O,null),O.several=_.bind(i,O,null),O.oneUrl=_.bind(j,O,null),O.allUrl=_.bind(k,O,null),O.stripRestangular=_.bind(p,O),O.restangularizeElement=_.bind(s,O),O.restangularizeCollection=_.bind(u,O),O}return e(b)}]})}();
|
Binary file
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// Karma configuration
|
2
|
+
// Generated on Fri Aug 09 2013 14:14:35 GMT-0500 (CDT)
|
3
|
+
|
4
|
+
module.exports = function(config) {
|
5
|
+
config.set({
|
6
|
+
|
7
|
+
// base path, that will be used to resolve files and exclude
|
8
|
+
basePath: '',
|
9
|
+
|
10
|
+
frameworks: ["jasmine"],
|
11
|
+
|
12
|
+
// list of files / patterns to load in the browser
|
13
|
+
files: [
|
14
|
+
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.12/angular.js',
|
15
|
+
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.12/angular-mocks.js',
|
16
|
+
'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.3.0/lodash.js',
|
17
|
+
'src/restangular.js',
|
18
|
+
'test/*.js'
|
19
|
+
],
|
20
|
+
|
21
|
+
|
22
|
+
// list of files to exclude
|
23
|
+
exclude: [
|
24
|
+
|
25
|
+
],
|
26
|
+
|
27
|
+
|
28
|
+
// test results reporter to use
|
29
|
+
// possible values: 'dots', 'progress', 'junit'
|
30
|
+
reporters: ['mocha'],
|
31
|
+
|
32
|
+
|
33
|
+
// web server port
|
34
|
+
port: 9876,
|
35
|
+
|
36
|
+
|
37
|
+
// cli runner port
|
38
|
+
runnerPort: 9100,
|
39
|
+
|
40
|
+
|
41
|
+
// enable / disable colors in the output (reporters and logs)
|
42
|
+
colors: true,
|
43
|
+
|
44
|
+
|
45
|
+
// level of logging
|
46
|
+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
47
|
+
logLevel: config.LOG_INFO,
|
48
|
+
|
49
|
+
|
50
|
+
// enable / disable watching file and executing tests whenever any file changes
|
51
|
+
autoWatch: true,
|
52
|
+
|
53
|
+
|
54
|
+
// Start these browsers, currently available:
|
55
|
+
// - Chrome
|
56
|
+
// - ChromeCanary
|
57
|
+
// - Firefox
|
58
|
+
// - Opera
|
59
|
+
// - Safari (only Mac)
|
60
|
+
// - PhantomJS
|
61
|
+
// - IE (only Windows)
|
62
|
+
browsers: ['PhantomJS'],
|
63
|
+
|
64
|
+
|
65
|
+
// If browser does not capture in given timeout [ms], kill it
|
66
|
+
captureTimeout: 60000,
|
67
|
+
|
68
|
+
|
69
|
+
// Continuous Integration mode
|
70
|
+
// if true, it capture browsers, run tests and exit
|
71
|
+
singleRun: false
|
72
|
+
|
73
|
+
});
|
74
|
+
};
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// Karma configuration
|
2
|
+
// Generated on Fri Aug 09 2013 14:14:35 GMT-0500 (CDT)
|
3
|
+
|
4
|
+
module.exports = function(config) {
|
5
|
+
config.set({
|
6
|
+
|
7
|
+
// base path, that will be used to resolve files and exclude
|
8
|
+
basePath: '',
|
9
|
+
|
10
|
+
frameworks: ["jasmine"],
|
11
|
+
|
12
|
+
// list of files / patterns to load in the browser
|
13
|
+
files: [
|
14
|
+
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular.js',
|
15
|
+
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular-mocks.js',
|
16
|
+
'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.1/underscore.js',
|
17
|
+
'src/restangular.js',
|
18
|
+
'test/*.js'
|
19
|
+
],
|
20
|
+
|
21
|
+
|
22
|
+
// list of files to exclude
|
23
|
+
exclude: [
|
24
|
+
|
25
|
+
],
|
26
|
+
|
27
|
+
|
28
|
+
// test results reporter to use
|
29
|
+
// possible values: 'dots', 'progress', 'junit'
|
30
|
+
reporters: ['progress'],
|
31
|
+
|
32
|
+
|
33
|
+
// web server port
|
34
|
+
port: 9877,
|
35
|
+
|
36
|
+
|
37
|
+
// cli runner port
|
38
|
+
runnerPort: 9101,
|
39
|
+
|
40
|
+
|
41
|
+
// enable / disable colors in the output (reporters and logs)
|
42
|
+
colors: true,
|
43
|
+
|
44
|
+
|
45
|
+
// level of logging
|
46
|
+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
47
|
+
logLevel: config.LOG_INFO,
|
48
|
+
|
49
|
+
|
50
|
+
// enable / disable watching file and executing tests whenever any file changes
|
51
|
+
autoWatch: true,
|
52
|
+
|
53
|
+
|
54
|
+
// Start these browsers, currently available:
|
55
|
+
// - Chrome
|
56
|
+
// - ChromeCanary
|
57
|
+
// - Firefox
|
58
|
+
// - Opera
|
59
|
+
// - Safari (only Mac)
|
60
|
+
// - PhantomJS
|
61
|
+
// - IE (only Windows)
|
62
|
+
browsers: ['PhantomJS'],
|
63
|
+
|
64
|
+
|
65
|
+
// If browser does not capture in given timeout [ms], kill it
|
66
|
+
captureTimeout: 60000,
|
67
|
+
|
68
|
+
|
69
|
+
// Continuous Integration mode
|
70
|
+
// if true, it capture browsers, run tests and exit
|
71
|
+
singleRun: false
|
72
|
+
|
73
|
+
});
|
74
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013-2015 Martin Gontovnikas http://www.gon.to/
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
{
|
2
|
+
"name": "restangular",
|
3
|
+
"description": "Restful Resources service for AngularJS apps",
|
4
|
+
"version": "1.5.1",
|
5
|
+
"filename": "restangular.min.js",
|
6
|
+
"main": "./dist/restangular.min.js",
|
7
|
+
"homepage": "https://github.com/mgonto/restangular",
|
8
|
+
"author": "Martin Gontovnikas <martin@gon.to>",
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "git://github.com/mgonto/restangular.git"
|
12
|
+
},
|
13
|
+
"engines": {
|
14
|
+
"node": ">= 0.9"
|
15
|
+
},
|
16
|
+
"keywords": [
|
17
|
+
"angular",
|
18
|
+
"client",
|
19
|
+
"browser",
|
20
|
+
"restful",
|
21
|
+
"resources",
|
22
|
+
"rest",
|
23
|
+
"api"
|
24
|
+
],
|
25
|
+
"maintainers": [
|
26
|
+
{
|
27
|
+
"name": "Martin Gontovnikas",
|
28
|
+
"website": "http://gon.to/"
|
29
|
+
}
|
30
|
+
],
|
31
|
+
"dependencies": {
|
32
|
+
"lodash": ">=1.3.0"
|
33
|
+
},
|
34
|
+
"devDependencies": {
|
35
|
+
"grunt-cli": ">= 0.1.7",
|
36
|
+
"grunt-contrib-concat": "*",
|
37
|
+
"grunt-contrib-jshint": "*",
|
38
|
+
"grunt-contrib-uglify": "*",
|
39
|
+
"grunt-bower": "*",
|
40
|
+
"grunt-bower-task": "*",
|
41
|
+
"grunt-karma": "latest",
|
42
|
+
"grunt-conventional-changelog": "0.0.12",
|
43
|
+
"grunt-zip": "*",
|
44
|
+
"karma": "~0.12.1",
|
45
|
+
"karma-mocha-reporter": "0.2.8",
|
46
|
+
"karma-jasmine": "~0.1.5",
|
47
|
+
"karma-chrome-launcher": "~0.1.2",
|
48
|
+
"karma-phantomjs-launcher": "~0.1.2",
|
49
|
+
"karma-firefox-launcher": "~0.1.3"
|
50
|
+
},
|
51
|
+
"scripts": {
|
52
|
+
"test": "grunt test --verbose"
|
53
|
+
},
|
54
|
+
"license": "MIT"
|
55
|
+
}
|
@@ -0,0 +1,1350 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
var restangular = angular.module('restangular', []);
|
4
|
+
|
5
|
+
restangular.provider('Restangular', function() {
|
6
|
+
// Configuration
|
7
|
+
var Configurer = {};
|
8
|
+
Configurer.init = function(object, config) {
|
9
|
+
object.configuration = config;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Those are HTTP safe methods for which there is no need to pass any data with the request.
|
13
|
+
*/
|
14
|
+
var safeMethods= ['get', 'head', 'options', 'trace', 'getlist'];
|
15
|
+
config.isSafe = function(operation) {
|
16
|
+
return _.contains(safeMethods, operation.toLowerCase());
|
17
|
+
};
|
18
|
+
|
19
|
+
var absolutePattern = /^https?:\/\//i;
|
20
|
+
config.isAbsoluteUrl = function(string) {
|
21
|
+
return _.isUndefined(config.absoluteUrl) || _.isNull(config.absoluteUrl) ?
|
22
|
+
string && absolutePattern.test(string) :
|
23
|
+
config.absoluteUrl;
|
24
|
+
};
|
25
|
+
|
26
|
+
config.absoluteUrl = _.isUndefined(config.absoluteUrl) ? true : config.absoluteUrl;
|
27
|
+
object.setSelfLinkAbsoluteUrl = function(value) {
|
28
|
+
config.absoluteUrl = value;
|
29
|
+
};
|
30
|
+
/**
|
31
|
+
* This is the BaseURL to be used with Restangular
|
32
|
+
*/
|
33
|
+
config.baseUrl = _.isUndefined(config.baseUrl) ? '' : config.baseUrl;
|
34
|
+
object.setBaseUrl = function(newBaseUrl) {
|
35
|
+
config.baseUrl = /\/$/.test(newBaseUrl) ?
|
36
|
+
newBaseUrl.substring(0, newBaseUrl.length-1) :
|
37
|
+
newBaseUrl;
|
38
|
+
return this;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Sets the extra fields to keep from the parents
|
43
|
+
*/
|
44
|
+
config.extraFields = config.extraFields || [];
|
45
|
+
object.setExtraFields = function(newExtraFields) {
|
46
|
+
config.extraFields = newExtraFields;
|
47
|
+
return this;
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Some default $http parameter to be used in EVERY call
|
52
|
+
**/
|
53
|
+
config.defaultHttpFields = config.defaultHttpFields || {};
|
54
|
+
object.setDefaultHttpFields = function(values) {
|
55
|
+
config.defaultHttpFields = values;
|
56
|
+
return this;
|
57
|
+
};
|
58
|
+
|
59
|
+
config.withHttpValues = function(httpLocalConfig, obj) {
|
60
|
+
return _.defaults(obj, httpLocalConfig, config.defaultHttpFields);
|
61
|
+
};
|
62
|
+
|
63
|
+
config.encodeIds = _.isUndefined(config.encodeIds) ? true : config.encodeIds;
|
64
|
+
object.setEncodeIds = function(encode) {
|
65
|
+
config.encodeIds = encode;
|
66
|
+
};
|
67
|
+
|
68
|
+
config.defaultRequestParams = config.defaultRequestParams || {
|
69
|
+
get: {},
|
70
|
+
post: {},
|
71
|
+
put: {},
|
72
|
+
remove: {},
|
73
|
+
common: {}
|
74
|
+
};
|
75
|
+
|
76
|
+
object.setDefaultRequestParams = function(param1, param2) {
|
77
|
+
var methods = [],
|
78
|
+
params = param2 || param1;
|
79
|
+
if (!_.isUndefined(param2)) {
|
80
|
+
if (_.isArray(param1)) {
|
81
|
+
methods = param1;
|
82
|
+
} else {
|
83
|
+
methods.push(param1);
|
84
|
+
}
|
85
|
+
} else {
|
86
|
+
methods.push('common');
|
87
|
+
}
|
88
|
+
|
89
|
+
_.each(methods, function (method) {
|
90
|
+
config.defaultRequestParams[method] = params;
|
91
|
+
});
|
92
|
+
return this;
|
93
|
+
};
|
94
|
+
|
95
|
+
object.requestParams = config.defaultRequestParams;
|
96
|
+
|
97
|
+
config.defaultHeaders = config.defaultHeaders || {};
|
98
|
+
object.setDefaultHeaders = function(headers) {
|
99
|
+
config.defaultHeaders = headers;
|
100
|
+
object.defaultHeaders = config.defaultHeaders;
|
101
|
+
return this;
|
102
|
+
};
|
103
|
+
|
104
|
+
object.defaultHeaders = config.defaultHeaders;
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Method overriders will set which methods are sent via POST with an X-HTTP-Method-Override
|
108
|
+
**/
|
109
|
+
config.methodOverriders = config.methodOverriders || [];
|
110
|
+
object.setMethodOverriders = function(values) {
|
111
|
+
var overriders = _.extend([], values);
|
112
|
+
if (config.isOverridenMethod('delete', overriders)) {
|
113
|
+
overriders.push('remove');
|
114
|
+
}
|
115
|
+
config.methodOverriders = overriders;
|
116
|
+
return this;
|
117
|
+
};
|
118
|
+
|
119
|
+
config.jsonp = _.isUndefined(config.jsonp) ? false : config.jsonp;
|
120
|
+
object.setJsonp = function(active) {
|
121
|
+
config.jsonp = active;
|
122
|
+
};
|
123
|
+
|
124
|
+
config.isOverridenMethod = function(method, values) {
|
125
|
+
var search = values || config.methodOverriders;
|
126
|
+
return !_.isUndefined(_.find(search, function(one) {
|
127
|
+
return one.toLowerCase() === method.toLowerCase();
|
128
|
+
}));
|
129
|
+
};
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Sets the URL creator type. For now, only Path is created. In the future we'll have queryParams
|
133
|
+
**/
|
134
|
+
config.urlCreator = config.urlCreator || 'path';
|
135
|
+
object.setUrlCreator = function(name) {
|
136
|
+
if (!_.has(config.urlCreatorFactory, name)) {
|
137
|
+
throw new Error('URL Path selected isn\'t valid');
|
138
|
+
}
|
139
|
+
|
140
|
+
config.urlCreator = name;
|
141
|
+
return this;
|
142
|
+
};
|
143
|
+
|
144
|
+
/**
|
145
|
+
* You can set the restangular fields here. The 3 required fields for Restangular are:
|
146
|
+
*
|
147
|
+
* id: Id of the element
|
148
|
+
* route: name of the route of this element
|
149
|
+
* parentResource: the reference to the parent resource
|
150
|
+
*
|
151
|
+
* All of this fields except for id, are handled (and created) by Restangular. By default,
|
152
|
+
* the field values will be id, route and parentResource respectively
|
153
|
+
*/
|
154
|
+
config.restangularFields = config.restangularFields || {
|
155
|
+
id: 'id',
|
156
|
+
route: 'route',
|
157
|
+
parentResource: 'parentResource',
|
158
|
+
restangularCollection: 'restangularCollection',
|
159
|
+
cannonicalId: '__cannonicalId',
|
160
|
+
etag: 'restangularEtag',
|
161
|
+
selfLink: 'href',
|
162
|
+
get: 'get',
|
163
|
+
getList: 'getList',
|
164
|
+
put: 'put',
|
165
|
+
post: 'post',
|
166
|
+
remove: 'remove',
|
167
|
+
head: 'head',
|
168
|
+
trace: 'trace',
|
169
|
+
options: 'options',
|
170
|
+
patch: 'patch',
|
171
|
+
getRestangularUrl: 'getRestangularUrl',
|
172
|
+
getRequestedUrl: 'getRequestedUrl',
|
173
|
+
putElement: 'putElement',
|
174
|
+
addRestangularMethod: 'addRestangularMethod',
|
175
|
+
getParentList: 'getParentList',
|
176
|
+
clone: 'clone',
|
177
|
+
ids: 'ids',
|
178
|
+
httpConfig: '_$httpConfig',
|
179
|
+
reqParams: 'reqParams',
|
180
|
+
one: 'one',
|
181
|
+
all: 'all',
|
182
|
+
several: 'several',
|
183
|
+
oneUrl: 'oneUrl',
|
184
|
+
allUrl: 'allUrl',
|
185
|
+
customPUT: 'customPUT',
|
186
|
+
customPOST: 'customPOST',
|
187
|
+
customDELETE: 'customDELETE',
|
188
|
+
customGET: 'customGET',
|
189
|
+
customGETLIST: 'customGETLIST',
|
190
|
+
customOperation: 'customOperation',
|
191
|
+
doPUT: 'doPUT',
|
192
|
+
doPOST: 'doPOST',
|
193
|
+
doDELETE: 'doDELETE',
|
194
|
+
doGET: 'doGET',
|
195
|
+
doGETLIST: 'doGETLIST',
|
196
|
+
fromServer: 'fromServer',
|
197
|
+
withConfig: 'withConfig',
|
198
|
+
withHttpConfig: 'withHttpConfig',
|
199
|
+
singleOne: 'singleOne',
|
200
|
+
plain: 'plain',
|
201
|
+
save: 'save',
|
202
|
+
restangularized: 'restangularized'
|
203
|
+
};
|
204
|
+
object.setRestangularFields = function(resFields) {
|
205
|
+
config.restangularFields =
|
206
|
+
_.extend(config.restangularFields, resFields);
|
207
|
+
return this;
|
208
|
+
};
|
209
|
+
|
210
|
+
config.isRestangularized = function(obj) {
|
211
|
+
return !!obj[config.restangularFields.restangularized];
|
212
|
+
};
|
213
|
+
|
214
|
+
config.setFieldToElem = function(field, elem, value) {
|
215
|
+
var properties = field.split('.');
|
216
|
+
var idValue = elem;
|
217
|
+
_.each(_.initial(properties), function(prop) {
|
218
|
+
idValue[prop] = {};
|
219
|
+
idValue = idValue[prop];
|
220
|
+
});
|
221
|
+
idValue[_.last(properties)] = value;
|
222
|
+
return this;
|
223
|
+
};
|
224
|
+
|
225
|
+
config.getFieldFromElem = function(field, elem) {
|
226
|
+
var properties = field.split('.');
|
227
|
+
var idValue = elem;
|
228
|
+
_.each(properties, function(prop) {
|
229
|
+
if (idValue) {
|
230
|
+
idValue = idValue[prop];
|
231
|
+
}
|
232
|
+
});
|
233
|
+
return angular.copy(idValue);
|
234
|
+
};
|
235
|
+
|
236
|
+
config.setIdToElem = function(elem, id /*, route */) {
|
237
|
+
config.setFieldToElem(config.restangularFields.id, elem, id);
|
238
|
+
return this;
|
239
|
+
};
|
240
|
+
|
241
|
+
config.getIdFromElem = function(elem) {
|
242
|
+
return config.getFieldFromElem(config.restangularFields.id, elem);
|
243
|
+
};
|
244
|
+
|
245
|
+
config.isValidId = function(elemId) {
|
246
|
+
return '' !== elemId && !_.isUndefined(elemId) && !_.isNull(elemId);
|
247
|
+
};
|
248
|
+
|
249
|
+
config.setUrlToElem = function(elem, url /*, route */) {
|
250
|
+
config.setFieldToElem(config.restangularFields.selfLink, elem, url);
|
251
|
+
return this;
|
252
|
+
};
|
253
|
+
|
254
|
+
config.getUrlFromElem = function(elem) {
|
255
|
+
return config.getFieldFromElem(config.restangularFields.selfLink, elem);
|
256
|
+
};
|
257
|
+
|
258
|
+
config.useCannonicalId = _.isUndefined(config.useCannonicalId) ? false : config.useCannonicalId;
|
259
|
+
object.setUseCannonicalId = function(value) {
|
260
|
+
config.useCannonicalId = value;
|
261
|
+
return this;
|
262
|
+
};
|
263
|
+
|
264
|
+
config.getCannonicalIdFromElem = function(elem) {
|
265
|
+
var cannonicalId = elem[config.restangularFields.cannonicalId];
|
266
|
+
var actualId = config.isValidId(cannonicalId) ? cannonicalId : config.getIdFromElem(elem);
|
267
|
+
return actualId;
|
268
|
+
};
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Sets the Response parser. This is used in case your response isn't directly the data.
|
272
|
+
* For example if you have a response like {meta: {'meta'}, data: {name: 'Gonto'}}
|
273
|
+
* you can extract this data which is the one that needs wrapping
|
274
|
+
*
|
275
|
+
* The ResponseExtractor is a function that receives the response and the method executed.
|
276
|
+
*/
|
277
|
+
|
278
|
+
config.responseInterceptors = config.responseInterceptors || [];
|
279
|
+
|
280
|
+
config.defaultResponseInterceptor = function(data /*, operation, what, url, response, deferred */) {
|
281
|
+
return data;
|
282
|
+
};
|
283
|
+
|
284
|
+
config.responseExtractor = function(data, operation, what, url, response, deferred) {
|
285
|
+
var interceptors = angular.copy(config.responseInterceptors);
|
286
|
+
interceptors.push(config.defaultResponseInterceptor);
|
287
|
+
var theData = data;
|
288
|
+
_.each(interceptors, function(interceptor) {
|
289
|
+
theData = interceptor(theData, operation,
|
290
|
+
what, url, response, deferred);
|
291
|
+
});
|
292
|
+
return theData;
|
293
|
+
};
|
294
|
+
|
295
|
+
object.addResponseInterceptor = function(extractor) {
|
296
|
+
config.responseInterceptors.push(extractor);
|
297
|
+
return this;
|
298
|
+
};
|
299
|
+
|
300
|
+
config.errorInterceptors = config.errorInterceptors || [];
|
301
|
+
object.addErrorInterceptor = function(interceptor) {
|
302
|
+
config.errorInterceptors.push(interceptor);
|
303
|
+
return this;
|
304
|
+
};
|
305
|
+
|
306
|
+
object.setResponseInterceptor = object.addResponseInterceptor;
|
307
|
+
object.setResponseExtractor = object.addResponseInterceptor;
|
308
|
+
object.setErrorInterceptor = object.addErrorInterceptor;
|
309
|
+
|
310
|
+
/**
|
311
|
+
* Response interceptor is called just before resolving promises.
|
312
|
+
*/
|
313
|
+
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Request interceptor is called before sending an object to the server.
|
317
|
+
*/
|
318
|
+
config.requestInterceptors = config.requestInterceptors || [];
|
319
|
+
|
320
|
+
config.defaultInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
|
321
|
+
return {
|
322
|
+
element: element,
|
323
|
+
headers: headers,
|
324
|
+
params: params,
|
325
|
+
httpConfig: httpConfig
|
326
|
+
};
|
327
|
+
};
|
328
|
+
|
329
|
+
config.fullRequestInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
|
330
|
+
var interceptors = angular.copy(config.requestInterceptors);
|
331
|
+
var defaultRequest = config.defaultInterceptor(element, operation, path, url, headers, params, httpConfig);
|
332
|
+
return _.reduce(interceptors, function(request, interceptor) {
|
333
|
+
return _.extend(request, interceptor(request.element, operation,
|
334
|
+
path, url, request.headers, request.params, request.httpConfig));
|
335
|
+
}, defaultRequest);
|
336
|
+
};
|
337
|
+
|
338
|
+
object.addRequestInterceptor = function(interceptor) {
|
339
|
+
config.requestInterceptors.push(function(elem, operation, path, url, headers, params, httpConfig) {
|
340
|
+
return {
|
341
|
+
headers: headers,
|
342
|
+
params: params,
|
343
|
+
element: interceptor(elem, operation, path, url),
|
344
|
+
httpConfig: httpConfig
|
345
|
+
};
|
346
|
+
});
|
347
|
+
return this;
|
348
|
+
};
|
349
|
+
|
350
|
+
object.setRequestInterceptor = object.addRequestInterceptor;
|
351
|
+
|
352
|
+
object.addFullRequestInterceptor = function(interceptor) {
|
353
|
+
config.requestInterceptors.push(interceptor);
|
354
|
+
return this;
|
355
|
+
};
|
356
|
+
|
357
|
+
object.setFullRequestInterceptor = object.addFullRequestInterceptor;
|
358
|
+
|
359
|
+
config.onBeforeElemRestangularized = config.onBeforeElemRestangularized || function(elem) {
|
360
|
+
return elem;
|
361
|
+
};
|
362
|
+
object.setOnBeforeElemRestangularized = function(post) {
|
363
|
+
config.onBeforeElemRestangularized = post;
|
364
|
+
return this;
|
365
|
+
};
|
366
|
+
|
367
|
+
object.setRestangularizePromiseInterceptor = function(interceptor) {
|
368
|
+
config.restangularizePromiseInterceptor = interceptor;
|
369
|
+
return this;
|
370
|
+
};
|
371
|
+
|
372
|
+
/**
|
373
|
+
* This method is called after an element has been "Restangularized".
|
374
|
+
*
|
375
|
+
* It receives the element, a boolean indicating if it's an element or a collection
|
376
|
+
* and the name of the model
|
377
|
+
*
|
378
|
+
*/
|
379
|
+
config.onElemRestangularized = config.onElemRestangularized || function(elem) {
|
380
|
+
return elem;
|
381
|
+
};
|
382
|
+
object.setOnElemRestangularized = function(post) {
|
383
|
+
config.onElemRestangularized = post;
|
384
|
+
return this;
|
385
|
+
};
|
386
|
+
|
387
|
+
config.shouldSaveParent = config.shouldSaveParent || function() {
|
388
|
+
return true;
|
389
|
+
};
|
390
|
+
object.setParentless = function(values) {
|
391
|
+
if (_.isArray(values)) {
|
392
|
+
config.shouldSaveParent = function(route) {
|
393
|
+
return !_.contains(values, route);
|
394
|
+
};
|
395
|
+
} else if (_.isBoolean(values)) {
|
396
|
+
config.shouldSaveParent = function() {
|
397
|
+
return !values;
|
398
|
+
};
|
399
|
+
}
|
400
|
+
return this;
|
401
|
+
};
|
402
|
+
|
403
|
+
/**
|
404
|
+
* This lets you set a suffix to every request.
|
405
|
+
*
|
406
|
+
* For example, if your api requires that for JSon requests you do /users/123.json, you can set that
|
407
|
+
* in here.
|
408
|
+
*
|
409
|
+
*
|
410
|
+
* By default, the suffix is null
|
411
|
+
*/
|
412
|
+
config.suffix = _.isUndefined(config.suffix) ? null : config.suffix;
|
413
|
+
object.setRequestSuffix = function(newSuffix) {
|
414
|
+
config.suffix = newSuffix;
|
415
|
+
return this;
|
416
|
+
};
|
417
|
+
|
418
|
+
/**
|
419
|
+
* Add element transformers for certain routes.
|
420
|
+
*/
|
421
|
+
config.transformers = config.transformers || {};
|
422
|
+
object.addElementTransformer = function(type, secondArg, thirdArg) {
|
423
|
+
var isCollection = null;
|
424
|
+
var transformer = null;
|
425
|
+
if (arguments.length === 2) {
|
426
|
+
transformer = secondArg;
|
427
|
+
} else {
|
428
|
+
transformer = thirdArg;
|
429
|
+
isCollection = secondArg;
|
430
|
+
}
|
431
|
+
|
432
|
+
var typeTransformers = config.transformers[type];
|
433
|
+
if (!typeTransformers) {
|
434
|
+
typeTransformers = config.transformers[type] = [];
|
435
|
+
}
|
436
|
+
|
437
|
+
typeTransformers.push(function(coll, elem) {
|
438
|
+
if (_.isNull(isCollection) || (coll === isCollection)) {
|
439
|
+
return transformer(elem);
|
440
|
+
}
|
441
|
+
return elem;
|
442
|
+
});
|
443
|
+
|
444
|
+
return object;
|
445
|
+
};
|
446
|
+
|
447
|
+
object.extendCollection = function(route, fn) {
|
448
|
+
return object.addElementTransformer(route, true, fn);
|
449
|
+
};
|
450
|
+
|
451
|
+
object.extendModel = function(route, fn) {
|
452
|
+
return object.addElementTransformer(route, false, fn);
|
453
|
+
};
|
454
|
+
|
455
|
+
config.transformElem = function(elem, isCollection, route, Restangular, force) {
|
456
|
+
if (!force && !config.transformLocalElements && !elem[config.restangularFields.fromServer]) {
|
457
|
+
return elem;
|
458
|
+
}
|
459
|
+
var typeTransformers = config.transformers[route];
|
460
|
+
var changedElem = elem;
|
461
|
+
if (typeTransformers) {
|
462
|
+
_.each(typeTransformers, function(transformer) {
|
463
|
+
changedElem = transformer(isCollection, changedElem);
|
464
|
+
});
|
465
|
+
}
|
466
|
+
return config.onElemRestangularized(changedElem, isCollection, route, Restangular);
|
467
|
+
};
|
468
|
+
|
469
|
+
config.transformLocalElements = _.isUndefined(config.transformLocalElements) ?
|
470
|
+
false :
|
471
|
+
config.transformLocalElements;
|
472
|
+
|
473
|
+
object.setTransformOnlyServerElements = function(active) {
|
474
|
+
config.transformLocalElements = !active;
|
475
|
+
};
|
476
|
+
|
477
|
+
config.fullResponse = _.isUndefined(config.fullResponse) ? false : config.fullResponse;
|
478
|
+
object.setFullResponse = function(full) {
|
479
|
+
config.fullResponse = full;
|
480
|
+
return this;
|
481
|
+
};
|
482
|
+
|
483
|
+
|
484
|
+
//Internal values and functions
|
485
|
+
config.urlCreatorFactory = {};
|
486
|
+
|
487
|
+
/**
|
488
|
+
* Base URL Creator. Base prototype for everything related to it
|
489
|
+
**/
|
490
|
+
|
491
|
+
var BaseCreator = function() {
|
492
|
+
};
|
493
|
+
|
494
|
+
BaseCreator.prototype.setConfig = function(config) {
|
495
|
+
this.config = config;
|
496
|
+
return this;
|
497
|
+
};
|
498
|
+
|
499
|
+
BaseCreator.prototype.parentsArray = function(current) {
|
500
|
+
var parents = [];
|
501
|
+
while(current) {
|
502
|
+
parents.push(current);
|
503
|
+
current = current[this.config.restangularFields.parentResource];
|
504
|
+
}
|
505
|
+
return parents.reverse();
|
506
|
+
};
|
507
|
+
|
508
|
+
function RestangularResource(config, $http, url, configurer) {
|
509
|
+
var resource = {};
|
510
|
+
_.each(_.keys(configurer), function(key) {
|
511
|
+
var value = configurer[key];
|
512
|
+
|
513
|
+
// Add default parameters
|
514
|
+
value.params = _.extend({}, value.params, config.defaultRequestParams[value.method.toLowerCase()]);
|
515
|
+
// We don't want the ? if no params are there
|
516
|
+
if (_.isEmpty(value.params)) {
|
517
|
+
delete value.params;
|
518
|
+
}
|
519
|
+
|
520
|
+
if (config.isSafe(value.method)) {
|
521
|
+
|
522
|
+
resource[key] = function() {
|
523
|
+
return $http(_.extend(value, {
|
524
|
+
url: url
|
525
|
+
}));
|
526
|
+
};
|
527
|
+
|
528
|
+
} else {
|
529
|
+
|
530
|
+
resource[key] = function(data) {
|
531
|
+
return $http(_.extend(value, {
|
532
|
+
url: url,
|
533
|
+
data: data
|
534
|
+
}));
|
535
|
+
};
|
536
|
+
|
537
|
+
}
|
538
|
+
});
|
539
|
+
|
540
|
+
return resource;
|
541
|
+
}
|
542
|
+
|
543
|
+
BaseCreator.prototype.resource = function(current, $http, localHttpConfig, callHeaders, callParams, what, etag,operation) {
|
544
|
+
|
545
|
+
var params = _.defaults(callParams || {}, this.config.defaultRequestParams.common);
|
546
|
+
var headers = _.defaults(callHeaders || {}, this.config.defaultHeaders);
|
547
|
+
|
548
|
+
if (etag) {
|
549
|
+
if (!config.isSafe(operation)) {
|
550
|
+
headers['If-Match'] = etag;
|
551
|
+
} else {
|
552
|
+
headers['If-None-Match'] = etag;
|
553
|
+
}
|
554
|
+
}
|
555
|
+
|
556
|
+
var url = this.base(current);
|
557
|
+
|
558
|
+
if (what) {
|
559
|
+
var add = '';
|
560
|
+
if (!/\/$/.test(url)) {
|
561
|
+
add += '/';
|
562
|
+
}
|
563
|
+
add += what;
|
564
|
+
url += add;
|
565
|
+
}
|
566
|
+
|
567
|
+
if (this.config.suffix &&
|
568
|
+
url.indexOf(this.config.suffix, url.length - this.config.suffix.length) === -1 &&
|
569
|
+
!this.config.getUrlFromElem(current)) {
|
570
|
+
url += this.config.suffix;
|
571
|
+
}
|
572
|
+
|
573
|
+
current[this.config.restangularFields.httpConfig] = undefined;
|
574
|
+
|
575
|
+
return RestangularResource(this.config, $http, url, {
|
576
|
+
getList: this.config.withHttpValues(localHttpConfig,
|
577
|
+
{method: 'GET',
|
578
|
+
params: params,
|
579
|
+
headers: headers}),
|
580
|
+
|
581
|
+
get: this.config.withHttpValues(localHttpConfig,
|
582
|
+
{method: 'GET',
|
583
|
+
params: params,
|
584
|
+
headers: headers}),
|
585
|
+
|
586
|
+
jsonp: this.config.withHttpValues(localHttpConfig,
|
587
|
+
{method: 'jsonp',
|
588
|
+
params: params,
|
589
|
+
headers: headers}),
|
590
|
+
|
591
|
+
put: this.config.withHttpValues(localHttpConfig,
|
592
|
+
{method: 'PUT',
|
593
|
+
params: params,
|
594
|
+
headers: headers}),
|
595
|
+
|
596
|
+
post: this.config.withHttpValues(localHttpConfig,
|
597
|
+
{method: 'POST',
|
598
|
+
params: params,
|
599
|
+
headers: headers}),
|
600
|
+
|
601
|
+
remove: this.config.withHttpValues(localHttpConfig,
|
602
|
+
{method: 'DELETE',
|
603
|
+
params: params,
|
604
|
+
headers: headers}),
|
605
|
+
|
606
|
+
head: this.config.withHttpValues(localHttpConfig,
|
607
|
+
{method: 'HEAD',
|
608
|
+
params: params,
|
609
|
+
headers: headers}),
|
610
|
+
|
611
|
+
trace: this.config.withHttpValues(localHttpConfig,
|
612
|
+
{method: 'TRACE',
|
613
|
+
params: params,
|
614
|
+
headers: headers}),
|
615
|
+
|
616
|
+
options: this.config.withHttpValues(localHttpConfig,
|
617
|
+
{method: 'OPTIONS',
|
618
|
+
params: params,
|
619
|
+
headers: headers}),
|
620
|
+
|
621
|
+
patch: this.config.withHttpValues(localHttpConfig,
|
622
|
+
{method: 'PATCH',
|
623
|
+
params: params,
|
624
|
+
headers: headers})
|
625
|
+
});
|
626
|
+
};
|
627
|
+
|
628
|
+
/**
|
629
|
+
* This is the Path URL creator. It uses Path to show Hierarchy in the Rest API.
|
630
|
+
* This means that if you have an Account that then has a set of Buildings, a URL to a building
|
631
|
+
* would be /accounts/123/buildings/456
|
632
|
+
**/
|
633
|
+
var Path = function() {
|
634
|
+
};
|
635
|
+
|
636
|
+
Path.prototype = new BaseCreator();
|
637
|
+
|
638
|
+
Path.prototype.normalizeUrl = function (url){
|
639
|
+
var parts = /(http[s]?:\/\/)?(.*)?/.exec(url);
|
640
|
+
parts[2] = parts[2].replace(/[\\\/]+/g, '/');
|
641
|
+
return (typeof parts[1] !== 'undefined')? parts[1] + parts[2] : parts[2];
|
642
|
+
};
|
643
|
+
|
644
|
+
Path.prototype.base = function(current) {
|
645
|
+
var __this = this;
|
646
|
+
return _.reduce(this.parentsArray(current), function(acum, elem) {
|
647
|
+
var elemUrl;
|
648
|
+
var elemSelfLink = __this.config.getUrlFromElem(elem);
|
649
|
+
if (elemSelfLink) {
|
650
|
+
if (__this.config.isAbsoluteUrl(elemSelfLink)) {
|
651
|
+
return elemSelfLink;
|
652
|
+
} else {
|
653
|
+
elemUrl = elemSelfLink;
|
654
|
+
}
|
655
|
+
} else {
|
656
|
+
elemUrl = elem[__this.config.restangularFields.route];
|
657
|
+
|
658
|
+
if (elem[__this.config.restangularFields.restangularCollection]) {
|
659
|
+
var ids = elem[__this.config.restangularFields.ids];
|
660
|
+
if (ids) {
|
661
|
+
elemUrl += '/' + ids.join(',');
|
662
|
+
}
|
663
|
+
} else {
|
664
|
+
var elemId;
|
665
|
+
if (__this.config.useCannonicalId) {
|
666
|
+
elemId = __this.config.getCannonicalIdFromElem(elem);
|
667
|
+
} else {
|
668
|
+
elemId = __this.config.getIdFromElem(elem);
|
669
|
+
}
|
670
|
+
|
671
|
+
if (config.isValidId(elemId) && !elem.singleOne) {
|
672
|
+
elemUrl += '/' + (__this.config.encodeIds ? encodeURIComponent(elemId) : elemId);
|
673
|
+
}
|
674
|
+
}
|
675
|
+
}
|
676
|
+
acum = acum.replace(/\/$/, '') + '/' + elemUrl;
|
677
|
+
return __this.normalizeUrl(acum);
|
678
|
+
|
679
|
+
}, this.config.baseUrl);
|
680
|
+
};
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
Path.prototype.fetchUrl = function(current, what) {
|
685
|
+
var baseUrl = this.base(current);
|
686
|
+
if (what) {
|
687
|
+
baseUrl += '/' + what;
|
688
|
+
}
|
689
|
+
return baseUrl;
|
690
|
+
};
|
691
|
+
|
692
|
+
Path.prototype.fetchRequestedUrl = function(current, what) {
|
693
|
+
var url = this.fetchUrl(current, what);
|
694
|
+
var params = current[config.restangularFields.reqParams];
|
695
|
+
|
696
|
+
// From here on and until the end of fetchRequestedUrl,
|
697
|
+
// the code has been kindly borrowed from angular.js
|
698
|
+
// The reason for such code bloating is coherence:
|
699
|
+
// If the user were to use this for cache management, the
|
700
|
+
// serialization of parameters would need to be identical
|
701
|
+
// to the one done by angular for cache keys to match.
|
702
|
+
function sortedKeys(obj) {
|
703
|
+
var keys = [];
|
704
|
+
for (var key in obj) {
|
705
|
+
if (obj.hasOwnProperty(key)) {
|
706
|
+
keys.push(key);
|
707
|
+
}
|
708
|
+
}
|
709
|
+
return keys.sort();
|
710
|
+
}
|
711
|
+
|
712
|
+
function forEachSorted(obj, iterator, context) {
|
713
|
+
var keys = sortedKeys(obj);
|
714
|
+
for ( var i = 0; i < keys.length; i++) {
|
715
|
+
iterator.call(context, obj[keys[i]], keys[i]);
|
716
|
+
}
|
717
|
+
return keys;
|
718
|
+
}
|
719
|
+
|
720
|
+
function encodeUriQuery(val, pctEncodeSpaces) {
|
721
|
+
return encodeURIComponent(val).
|
722
|
+
replace(/%40/gi, '@').
|
723
|
+
replace(/%3A/gi, ':').
|
724
|
+
replace(/%24/g, '$').
|
725
|
+
replace(/%2C/gi, ',').
|
726
|
+
replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
|
727
|
+
}
|
728
|
+
|
729
|
+
if (!params) { return url + (this.config.suffix || ''); }
|
730
|
+
|
731
|
+
var parts = [];
|
732
|
+
forEachSorted(params, function(value, key) {
|
733
|
+
if (value === null || value === undefined) { return; }
|
734
|
+
if (!angular.isArray(value)) { value = [value]; }
|
735
|
+
|
736
|
+
angular.forEach(value, function(v) {
|
737
|
+
if (angular.isObject(v)) {
|
738
|
+
v = angular.toJson(v);
|
739
|
+
}
|
740
|
+
parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(v));
|
741
|
+
});
|
742
|
+
});
|
743
|
+
|
744
|
+
return url + (this.config.suffix || '') + ((url.indexOf('?') === -1) ? '?' : '&') + parts.join('&');
|
745
|
+
};
|
746
|
+
|
747
|
+
config.urlCreatorFactory.path = Path;
|
748
|
+
};
|
749
|
+
|
750
|
+
var globalConfiguration = {};
|
751
|
+
|
752
|
+
Configurer.init(this, globalConfiguration);
|
753
|
+
|
754
|
+
|
755
|
+
|
756
|
+
this.$get = ['$http', '$q', function($http, $q) {
|
757
|
+
|
758
|
+
function createServiceForConfiguration(config) {
|
759
|
+
var service = {};
|
760
|
+
|
761
|
+
var urlHandler = new config.urlCreatorFactory[config.urlCreator]();
|
762
|
+
urlHandler.setConfig(config);
|
763
|
+
|
764
|
+
function restangularizeBase(parent, elem, route, reqParams, fromServer) {
|
765
|
+
elem[config.restangularFields.route] = route;
|
766
|
+
elem[config.restangularFields.getRestangularUrl] = _.bind(urlHandler.fetchUrl, urlHandler, elem);
|
767
|
+
elem[config.restangularFields.getRequestedUrl] = _.bind(urlHandler.fetchRequestedUrl, urlHandler, elem);
|
768
|
+
elem[config.restangularFields.addRestangularMethod] = _.bind(addRestangularMethodFunction, elem);
|
769
|
+
elem[config.restangularFields.clone] = _.bind(copyRestangularizedElement, elem, elem);
|
770
|
+
elem[config.restangularFields.reqParams] = _.isEmpty(reqParams) ? null : reqParams;
|
771
|
+
elem[config.restangularFields.withHttpConfig] = _.bind(withHttpConfig, elem);
|
772
|
+
elem[config.restangularFields.plain] = _.bind(stripRestangular, elem, elem);
|
773
|
+
|
774
|
+
// Tag element as restangularized
|
775
|
+
elem[config.restangularFields.restangularized] = true;
|
776
|
+
|
777
|
+
// RequestLess connection
|
778
|
+
elem[config.restangularFields.one] = _.bind(one, elem, elem);
|
779
|
+
elem[config.restangularFields.all] = _.bind(all, elem, elem);
|
780
|
+
elem[config.restangularFields.several] = _.bind(several, elem, elem);
|
781
|
+
elem[config.restangularFields.oneUrl] = _.bind(oneUrl, elem, elem);
|
782
|
+
elem[config.restangularFields.allUrl] = _.bind(allUrl, elem, elem);
|
783
|
+
|
784
|
+
elem[config.restangularFields.fromServer] = !!fromServer;
|
785
|
+
|
786
|
+
if (parent && config.shouldSaveParent(route)) {
|
787
|
+
var parentId = config.getIdFromElem(parent);
|
788
|
+
var parentUrl = config.getUrlFromElem(parent);
|
789
|
+
|
790
|
+
var restangularFieldsForParent = _.union(
|
791
|
+
_.values( _.pick(config.restangularFields, ['route', 'singleOne', 'parentResource']) ),
|
792
|
+
config.extraFields
|
793
|
+
);
|
794
|
+
var parentResource = _.pick(parent, restangularFieldsForParent);
|
795
|
+
|
796
|
+
if (config.isValidId(parentId)) {
|
797
|
+
config.setIdToElem(parentResource, parentId, route);
|
798
|
+
}
|
799
|
+
if (config.isValidId(parentUrl)) {
|
800
|
+
config.setUrlToElem(parentResource, parentUrl, route);
|
801
|
+
}
|
802
|
+
|
803
|
+
elem[config.restangularFields.parentResource] = parentResource;
|
804
|
+
} else {
|
805
|
+
elem[config.restangularFields.parentResource] = null;
|
806
|
+
}
|
807
|
+
return elem;
|
808
|
+
}
|
809
|
+
|
810
|
+
function one(parent, route, id, singleOne) {
|
811
|
+
var error;
|
812
|
+
if (_.isNumber(route) || _.isNumber(parent)) {
|
813
|
+
error = 'You\'re creating a Restangular entity with the number ';
|
814
|
+
error += 'instead of the route or the parent. For example, you can\'t call .one(12).';
|
815
|
+
throw new Error(error);
|
816
|
+
}
|
817
|
+
if (_.isUndefined(route)) {
|
818
|
+
error = 'You\'re creating a Restangular entity either without the path. ';
|
819
|
+
error += 'For example you can\'t call .one(). Please check if your arguments are valid.';
|
820
|
+
throw new Error(error);
|
821
|
+
}
|
822
|
+
var elem = {};
|
823
|
+
config.setIdToElem(elem, id, route);
|
824
|
+
config.setFieldToElem(config.restangularFields.singleOne, elem, singleOne);
|
825
|
+
return restangularizeElem(parent, elem , route, false);
|
826
|
+
}
|
827
|
+
|
828
|
+
|
829
|
+
function all(parent, route) {
|
830
|
+
return restangularizeCollection(parent, [] , route, false);
|
831
|
+
}
|
832
|
+
|
833
|
+
function several(parent, route /*, ids */) {
|
834
|
+
var collection = [];
|
835
|
+
collection[config.restangularFields.ids] = Array.prototype.splice.call(arguments, 2);
|
836
|
+
return restangularizeCollection(parent, collection , route, false);
|
837
|
+
}
|
838
|
+
|
839
|
+
function oneUrl(parent, route, url) {
|
840
|
+
if (!route) {
|
841
|
+
throw new Error('Route is mandatory when creating new Restangular objects.');
|
842
|
+
}
|
843
|
+
var elem = {};
|
844
|
+
config.setUrlToElem(elem, url, route);
|
845
|
+
return restangularizeElem(parent, elem , route, false);
|
846
|
+
}
|
847
|
+
|
848
|
+
|
849
|
+
function allUrl(parent, route, url) {
|
850
|
+
if (!route) {
|
851
|
+
throw new Error('Route is mandatory when creating new Restangular objects.');
|
852
|
+
}
|
853
|
+
var elem = {};
|
854
|
+
config.setUrlToElem(elem, url, route);
|
855
|
+
return restangularizeCollection(parent, elem , route, false);
|
856
|
+
}
|
857
|
+
// Promises
|
858
|
+
function restangularizePromise(promise, isCollection, valueToFill) {
|
859
|
+
promise.call = _.bind(promiseCall, promise);
|
860
|
+
promise.get = _.bind(promiseGet, promise);
|
861
|
+
promise[config.restangularFields.restangularCollection] = isCollection;
|
862
|
+
if (isCollection) {
|
863
|
+
promise.push = _.bind(promiseCall, promise, 'push');
|
864
|
+
}
|
865
|
+
promise.$object = valueToFill;
|
866
|
+
if (config.restangularizePromiseInterceptor) {
|
867
|
+
config.restangularizePromiseInterceptor(promise);
|
868
|
+
}
|
869
|
+
return promise;
|
870
|
+
}
|
871
|
+
|
872
|
+
function promiseCall(method) {
|
873
|
+
var deferred = $q.defer();
|
874
|
+
var callArgs = arguments;
|
875
|
+
var filledValue = {};
|
876
|
+
this.then(function(val) {
|
877
|
+
var params = Array.prototype.slice.call(callArgs, 1);
|
878
|
+
var func = val[method];
|
879
|
+
func.apply(val, params);
|
880
|
+
filledValue = val;
|
881
|
+
deferred.resolve(val);
|
882
|
+
});
|
883
|
+
return restangularizePromise(deferred.promise, this[config.restangularFields.restangularCollection], filledValue);
|
884
|
+
}
|
885
|
+
|
886
|
+
function promiseGet(what) {
|
887
|
+
var deferred = $q.defer();
|
888
|
+
var filledValue = {};
|
889
|
+
this.then(function(val) {
|
890
|
+
filledValue = val[what];
|
891
|
+
deferred.resolve(filledValue);
|
892
|
+
});
|
893
|
+
return restangularizePromise(deferred.promise, this[config.restangularFields.restangularCollection], filledValue);
|
894
|
+
}
|
895
|
+
|
896
|
+
function resolvePromise(deferred, response, data, filledValue) {
|
897
|
+
_.extend(filledValue, data);
|
898
|
+
|
899
|
+
// Trigger the full response interceptor.
|
900
|
+
if (config.fullResponse) {
|
901
|
+
return deferred.resolve(_.extend(response, {
|
902
|
+
data: data
|
903
|
+
}));
|
904
|
+
} else {
|
905
|
+
deferred.resolve(data);
|
906
|
+
}
|
907
|
+
}
|
908
|
+
|
909
|
+
|
910
|
+
// Elements
|
911
|
+
function stripRestangular(elem) {
|
912
|
+
if (_.isArray(elem)) {
|
913
|
+
var array = [];
|
914
|
+
_.each(elem, function(value) {
|
915
|
+
array.push(config.isRestangularized(value) ? stripRestangular(value) : value);
|
916
|
+
});
|
917
|
+
return array;
|
918
|
+
} else {
|
919
|
+
return _.omit(elem, _.values(_.omit(config.restangularFields, 'id')));
|
920
|
+
}
|
921
|
+
}
|
922
|
+
|
923
|
+
function addCustomOperation(elem) {
|
924
|
+
elem[config.restangularFields.customOperation] = _.bind(customFunction, elem);
|
925
|
+
_.each(['put', 'post', 'get', 'delete'], function(oper) {
|
926
|
+
_.each(['do', 'custom'], function(alias) {
|
927
|
+
var callOperation = oper === 'delete' ? 'remove' : oper;
|
928
|
+
var name = alias + oper.toUpperCase();
|
929
|
+
var callFunction;
|
930
|
+
|
931
|
+
if (callOperation !== 'put' && callOperation !== 'post') {
|
932
|
+
callFunction = customFunction;
|
933
|
+
} else {
|
934
|
+
callFunction = function(operation, elem, path, params, headers) {
|
935
|
+
return _.bind(customFunction, this)(operation, path, params, headers, elem);
|
936
|
+
};
|
937
|
+
}
|
938
|
+
elem[name] = _.bind(callFunction, elem, callOperation);
|
939
|
+
});
|
940
|
+
});
|
941
|
+
elem[config.restangularFields.customGETLIST] = _.bind(fetchFunction, elem);
|
942
|
+
elem[config.restangularFields.doGETLIST] = elem[config.restangularFields.customGETLIST];
|
943
|
+
}
|
944
|
+
|
945
|
+
function copyRestangularizedElement(fromElement, toElement) {
|
946
|
+
var copiedElement = angular.copy(fromElement, toElement);
|
947
|
+
return restangularizeElem(copiedElement[config.restangularFields.parentResource],
|
948
|
+
copiedElement, copiedElement[config.restangularFields.route], true);
|
949
|
+
}
|
950
|
+
|
951
|
+
function restangularizeElem(parent, element, route, fromServer, collection, reqParams) {
|
952
|
+
var elem = config.onBeforeElemRestangularized(element, false, route);
|
953
|
+
|
954
|
+
var localElem = restangularizeBase(parent, elem, route, reqParams, fromServer);
|
955
|
+
|
956
|
+
if (config.useCannonicalId) {
|
957
|
+
localElem[config.restangularFields.cannonicalId] = config.getIdFromElem(localElem);
|
958
|
+
}
|
959
|
+
|
960
|
+
if (collection) {
|
961
|
+
localElem[config.restangularFields.getParentList] = function() {
|
962
|
+
return collection;
|
963
|
+
};
|
964
|
+
}
|
965
|
+
|
966
|
+
localElem[config.restangularFields.restangularCollection] = false;
|
967
|
+
localElem[config.restangularFields.get] = _.bind(getFunction, localElem);
|
968
|
+
localElem[config.restangularFields.getList] = _.bind(fetchFunction, localElem);
|
969
|
+
localElem[config.restangularFields.put] = _.bind(putFunction, localElem);
|
970
|
+
localElem[config.restangularFields.post] = _.bind(postFunction, localElem);
|
971
|
+
localElem[config.restangularFields.remove] = _.bind(deleteFunction, localElem);
|
972
|
+
localElem[config.restangularFields.head] = _.bind(headFunction, localElem);
|
973
|
+
localElem[config.restangularFields.trace] = _.bind(traceFunction, localElem);
|
974
|
+
localElem[config.restangularFields.options] = _.bind(optionsFunction, localElem);
|
975
|
+
localElem[config.restangularFields.patch] = _.bind(patchFunction, localElem);
|
976
|
+
localElem[config.restangularFields.save] = _.bind(save, localElem);
|
977
|
+
|
978
|
+
addCustomOperation(localElem);
|
979
|
+
return config.transformElem(localElem, false, route, service, true);
|
980
|
+
}
|
981
|
+
|
982
|
+
function restangularizeCollection(parent, element, route, fromServer, reqParams) {
|
983
|
+
var elem = config.onBeforeElemRestangularized(element, true, route);
|
984
|
+
|
985
|
+
var localElem = restangularizeBase(parent, elem, route, reqParams, fromServer);
|
986
|
+
localElem[config.restangularFields.restangularCollection] = true;
|
987
|
+
localElem[config.restangularFields.post] = _.bind(postFunction, localElem, null);
|
988
|
+
localElem[config.restangularFields.remove] = _.bind(deleteFunction, localElem);
|
989
|
+
localElem[config.restangularFields.head] = _.bind(headFunction, localElem);
|
990
|
+
localElem[config.restangularFields.trace] = _.bind(traceFunction, localElem);
|
991
|
+
localElem[config.restangularFields.putElement] = _.bind(putElementFunction, localElem);
|
992
|
+
localElem[config.restangularFields.options] = _.bind(optionsFunction, localElem);
|
993
|
+
localElem[config.restangularFields.patch] = _.bind(patchFunction, localElem);
|
994
|
+
localElem[config.restangularFields.get] = _.bind(getById, localElem);
|
995
|
+
localElem[config.restangularFields.getList] = _.bind(fetchFunction, localElem, null);
|
996
|
+
|
997
|
+
addCustomOperation(localElem);
|
998
|
+
return config.transformElem(localElem, true, route, service, true);
|
999
|
+
}
|
1000
|
+
|
1001
|
+
function restangularizeCollectionAndElements(parent, element, route) {
|
1002
|
+
var collection = restangularizeCollection(parent, element, route, false);
|
1003
|
+
_.each(collection, function(elem) {
|
1004
|
+
restangularizeElem(parent, elem, route, false);
|
1005
|
+
});
|
1006
|
+
return collection;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
function getById(id, reqParams, headers){
|
1010
|
+
return this.customGET(id.toString(), reqParams, headers);
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
function putElementFunction(idx, params, headers) {
|
1014
|
+
var __this = this;
|
1015
|
+
var elemToPut = this[idx];
|
1016
|
+
var deferred = $q.defer();
|
1017
|
+
var filledArray = [];
|
1018
|
+
filledArray = config.transformElem(filledArray, true, elemToPut[config.restangularFields.route], service);
|
1019
|
+
elemToPut.put(params, headers).then(function(serverElem) {
|
1020
|
+
var newArray = copyRestangularizedElement(__this);
|
1021
|
+
newArray[idx] = serverElem;
|
1022
|
+
filledArray = newArray;
|
1023
|
+
deferred.resolve(newArray);
|
1024
|
+
}, function(response) {
|
1025
|
+
deferred.reject(response);
|
1026
|
+
});
|
1027
|
+
|
1028
|
+
return restangularizePromise(deferred.promise, true, filledArray);
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
function parseResponse(resData, operation, route, fetchUrl, response, deferred) {
|
1032
|
+
var data = config.responseExtractor(resData, operation, route, fetchUrl, response, deferred);
|
1033
|
+
var etag = response.headers('ETag');
|
1034
|
+
if (data && etag) {
|
1035
|
+
data[config.restangularFields.etag] = etag;
|
1036
|
+
}
|
1037
|
+
return data;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
|
1041
|
+
function fetchFunction(what, reqParams, headers) {
|
1042
|
+
var __this = this;
|
1043
|
+
var deferred = $q.defer();
|
1044
|
+
var operation = 'getList';
|
1045
|
+
var url = urlHandler.fetchUrl(this, what);
|
1046
|
+
var whatFetched = what || __this[config.restangularFields.route];
|
1047
|
+
|
1048
|
+
var request = config.fullRequestInterceptor(null, operation,
|
1049
|
+
whatFetched, url, headers || {}, reqParams || {}, this[config.restangularFields.httpConfig] || {});
|
1050
|
+
|
1051
|
+
var filledArray = [];
|
1052
|
+
filledArray = config.transformElem(filledArray, true, whatFetched, service);
|
1053
|
+
|
1054
|
+
var method = 'getList';
|
1055
|
+
|
1056
|
+
if (config.jsonp) {
|
1057
|
+
method = 'jsonp';
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
var okCallback = function(response) {
|
1061
|
+
var resData = response.data;
|
1062
|
+
var fullParams = response.config.params;
|
1063
|
+
var data = parseResponse(resData, operation, whatFetched, url, response, deferred);
|
1064
|
+
|
1065
|
+
// support empty response for getList() calls (some APIs respond with 204 and empty body)
|
1066
|
+
if (_.isUndefined(data) || '' === data) {
|
1067
|
+
data = [];
|
1068
|
+
}
|
1069
|
+
if (!_.isArray(data)) {
|
1070
|
+
throw new Error('Response for getList SHOULD be an array and not an object or something else');
|
1071
|
+
}
|
1072
|
+
var processedData = _.map(data, function(elem) {
|
1073
|
+
if (!__this[config.restangularFields.restangularCollection]) {
|
1074
|
+
return restangularizeElem(__this, elem, what, true, data);
|
1075
|
+
} else {
|
1076
|
+
return restangularizeElem(__this[config.restangularFields.parentResource],
|
1077
|
+
elem, __this[config.restangularFields.route], true, data);
|
1078
|
+
}
|
1079
|
+
});
|
1080
|
+
|
1081
|
+
processedData = _.extend(data, processedData);
|
1082
|
+
|
1083
|
+
if (!__this[config.restangularFields.restangularCollection]) {
|
1084
|
+
resolvePromise(
|
1085
|
+
deferred,
|
1086
|
+
response,
|
1087
|
+
restangularizeCollection(
|
1088
|
+
__this,
|
1089
|
+
processedData,
|
1090
|
+
what,
|
1091
|
+
true,
|
1092
|
+
fullParams
|
1093
|
+
),
|
1094
|
+
filledArray
|
1095
|
+
);
|
1096
|
+
} else {
|
1097
|
+
resolvePromise(
|
1098
|
+
deferred,
|
1099
|
+
response,
|
1100
|
+
restangularizeCollection(
|
1101
|
+
__this[config.restangularFields.parentResource],
|
1102
|
+
processedData,
|
1103
|
+
__this[config.restangularFields.route],
|
1104
|
+
true,
|
1105
|
+
fullParams
|
1106
|
+
),
|
1107
|
+
filledArray
|
1108
|
+
);
|
1109
|
+
}
|
1110
|
+
};
|
1111
|
+
|
1112
|
+
urlHandler.resource(this, $http, request.httpConfig, request.headers, request.params, what,
|
1113
|
+
this[config.restangularFields.etag], operation)[method]().then(okCallback, function error(response) {
|
1114
|
+
if (response.status === 304 && __this[config.restangularFields.restangularCollection]) {
|
1115
|
+
resolvePromise(deferred, response, __this, filledArray);
|
1116
|
+
} else if ( _.every(config.errorInterceptors, function(cb) { return cb(response, deferred, okCallback) !== false; }) ) {
|
1117
|
+
// triggered if no callback returns false
|
1118
|
+
deferred.reject(response);
|
1119
|
+
}
|
1120
|
+
});
|
1121
|
+
|
1122
|
+
return restangularizePromise(deferred.promise, true, filledArray);
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
function withHttpConfig(httpConfig) {
|
1126
|
+
this[config.restangularFields.httpConfig] = httpConfig;
|
1127
|
+
return this;
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
function save(params, headers) {
|
1131
|
+
if (this[config.restangularFields.fromServer]) {
|
1132
|
+
return this[config.restangularFields.put](params, headers);
|
1133
|
+
} else {
|
1134
|
+
return _.bind(elemFunction, this)('post', undefined, params, undefined, headers);
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
function elemFunction(operation, what, params, obj, headers) {
|
1139
|
+
var __this = this;
|
1140
|
+
var deferred = $q.defer();
|
1141
|
+
var resParams = params || {};
|
1142
|
+
var route = what || this[config.restangularFields.route];
|
1143
|
+
var fetchUrl = urlHandler.fetchUrl(this, what);
|
1144
|
+
|
1145
|
+
var callObj = obj || this;
|
1146
|
+
// fallback to etag on restangular object (since for custom methods we probably don't explicitly specify the etag field)
|
1147
|
+
var etag = callObj[config.restangularFields.etag] || (operation !== 'post' ? this[config.restangularFields.etag] : null);
|
1148
|
+
|
1149
|
+
if (_.isObject(callObj) && config.isRestangularized(callObj)) {
|
1150
|
+
callObj = stripRestangular(callObj);
|
1151
|
+
}
|
1152
|
+
var request = config.fullRequestInterceptor(callObj, operation, route, fetchUrl,
|
1153
|
+
headers || {}, resParams || {}, this[config.restangularFields.httpConfig] || {});
|
1154
|
+
|
1155
|
+
var filledObject = {};
|
1156
|
+
filledObject = config.transformElem(filledObject, false, route, service);
|
1157
|
+
|
1158
|
+
var okCallback = function(response) {
|
1159
|
+
var resData = response.data;
|
1160
|
+
var fullParams = response.config.params;
|
1161
|
+
var elem = parseResponse(resData, operation, route, fetchUrl, response, deferred);
|
1162
|
+
if (elem) {
|
1163
|
+
|
1164
|
+
if (operation === 'post' && !__this[config.restangularFields.restangularCollection]) {
|
1165
|
+
var data = restangularizeElem(
|
1166
|
+
__this[config.restangularFields.parentResource],
|
1167
|
+
elem,
|
1168
|
+
route,
|
1169
|
+
true,
|
1170
|
+
null,
|
1171
|
+
fullParams
|
1172
|
+
);
|
1173
|
+
resolvePromise(deferred, response, data, filledObject);
|
1174
|
+
} else {
|
1175
|
+
var data = restangularizeElem(
|
1176
|
+
__this[config.restangularFields.parentResource],
|
1177
|
+
elem,
|
1178
|
+
__this[config.restangularFields.route],
|
1179
|
+
true,
|
1180
|
+
null,
|
1181
|
+
fullParams
|
1182
|
+
);
|
1183
|
+
|
1184
|
+
data[config.restangularFields.singleOne] = __this[config.restangularFields.singleOne];
|
1185
|
+
resolvePromise(deferred, response, data, filledObject);
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
} else {
|
1189
|
+
resolvePromise(deferred, response, undefined, filledObject);
|
1190
|
+
}
|
1191
|
+
};
|
1192
|
+
|
1193
|
+
var errorCallback = function(response) {
|
1194
|
+
if (response.status === 304 && config.isSafe(operation)) {
|
1195
|
+
resolvePromise(deferred, response, __this, filledObject);
|
1196
|
+
} else if ( _.every(config.errorInterceptors, function(cb) { return cb(response, deferred, okCallback) !== false; }) ) {
|
1197
|
+
// triggered if no callback returns false
|
1198
|
+
deferred.reject(response);
|
1199
|
+
}
|
1200
|
+
};
|
1201
|
+
// Overriding HTTP Method
|
1202
|
+
var callOperation = operation;
|
1203
|
+
var callHeaders = _.extend({}, request.headers);
|
1204
|
+
var isOverrideOperation = config.isOverridenMethod(operation);
|
1205
|
+
if (isOverrideOperation) {
|
1206
|
+
callOperation = 'post';
|
1207
|
+
callHeaders = _.extend(callHeaders, {'X-HTTP-Method-Override': operation === 'remove' ? 'DELETE' : operation.toUpperCase()});
|
1208
|
+
} else if (config.jsonp && callOperation === 'get') {
|
1209
|
+
callOperation = 'jsonp';
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
if (config.isSafe(operation)) {
|
1213
|
+
if (isOverrideOperation) {
|
1214
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1215
|
+
what, etag, callOperation)[callOperation]({}).then(okCallback, errorCallback);
|
1216
|
+
} else {
|
1217
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1218
|
+
what, etag, callOperation)[callOperation]().then(okCallback, errorCallback);
|
1219
|
+
}
|
1220
|
+
} else {
|
1221
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1222
|
+
what, etag, callOperation)[callOperation](request.element).then(okCallback, errorCallback);
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
return restangularizePromise(deferred.promise, false, filledObject);
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
function getFunction(params, headers) {
|
1229
|
+
return _.bind(elemFunction, this)('get', undefined, params, undefined, headers);
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
function deleteFunction(params, headers) {
|
1233
|
+
return _.bind(elemFunction, this)('remove', undefined, params, undefined, headers);
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
function putFunction(params, headers) {
|
1237
|
+
return _.bind(elemFunction, this)('put', undefined, params, undefined, headers);
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
function postFunction(what, elem, params, headers) {
|
1241
|
+
return _.bind(elemFunction, this)('post', what, params, elem, headers);
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
function headFunction(params, headers) {
|
1245
|
+
return _.bind(elemFunction, this)('head', undefined, params, undefined, headers);
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
function traceFunction(params, headers) {
|
1249
|
+
return _.bind(elemFunction, this)('trace', undefined, params, undefined, headers);
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
function optionsFunction(params, headers) {
|
1253
|
+
return _.bind(elemFunction, this)('options', undefined, params, undefined, headers);
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
function patchFunction(elem, params, headers) {
|
1257
|
+
return _.bind(elemFunction, this)('patch', undefined, params, elem, headers);
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
function customFunction(operation, path, params, headers, elem) {
|
1261
|
+
return _.bind(elemFunction, this)(operation, path, params, elem, headers);
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
function addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem) {
|
1265
|
+
var bindedFunction;
|
1266
|
+
if (operation === 'getList') {
|
1267
|
+
bindedFunction = _.bind(fetchFunction, this, path);
|
1268
|
+
} else {
|
1269
|
+
bindedFunction = _.bind(customFunction, this, operation, path);
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
var createdFunction = function(params, headers, elem) {
|
1273
|
+
var callParams = _.defaults({
|
1274
|
+
params: params,
|
1275
|
+
headers: headers,
|
1276
|
+
elem: elem
|
1277
|
+
}, {
|
1278
|
+
params: defaultParams,
|
1279
|
+
headers: defaultHeaders,
|
1280
|
+
elem: defaultElem
|
1281
|
+
});
|
1282
|
+
return bindedFunction(callParams.params, callParams.headers, callParams.elem);
|
1283
|
+
};
|
1284
|
+
|
1285
|
+
if (config.isSafe(operation)) {
|
1286
|
+
this[name] = createdFunction;
|
1287
|
+
} else {
|
1288
|
+
this[name] = function(elem, params, headers) {
|
1289
|
+
return createdFunction(params, headers, elem);
|
1290
|
+
};
|
1291
|
+
}
|
1292
|
+
}
|
1293
|
+
|
1294
|
+
function withConfigurationFunction(configurer) {
|
1295
|
+
var newConfig = angular.copy(_.omit(config, 'configuration'));
|
1296
|
+
Configurer.init(newConfig, newConfig);
|
1297
|
+
configurer(newConfig);
|
1298
|
+
return createServiceForConfiguration(newConfig);
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
function toService(route, parent) {
|
1302
|
+
var knownCollectionMethods = _.values(config.restangularFields);
|
1303
|
+
var serv = {};
|
1304
|
+
var collection = (parent || service).all(route);
|
1305
|
+
serv.one = _.bind(one, (parent || service), parent, route);
|
1306
|
+
serv.post = _.bind(collection.post, collection);
|
1307
|
+
serv.getList = _.bind(collection.getList, collection);
|
1308
|
+
|
1309
|
+
for (var prop in collection) {
|
1310
|
+
if (collection.hasOwnProperty(prop) && _.isFunction(collection[prop]) && !_.contains(knownCollectionMethods, prop)) {
|
1311
|
+
serv[prop] = _.bind(collection[prop], collection);
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
return serv;
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
|
1319
|
+
Configurer.init(service, config);
|
1320
|
+
|
1321
|
+
service.copy = _.bind(copyRestangularizedElement, service);
|
1322
|
+
|
1323
|
+
service.service = _.bind(toService, service);
|
1324
|
+
|
1325
|
+
service.withConfig = _.bind(withConfigurationFunction, service);
|
1326
|
+
|
1327
|
+
service.one = _.bind(one, service, null);
|
1328
|
+
|
1329
|
+
service.all = _.bind(all, service, null);
|
1330
|
+
|
1331
|
+
service.several = _.bind(several, service, null);
|
1332
|
+
|
1333
|
+
service.oneUrl = _.bind(oneUrl, service, null);
|
1334
|
+
|
1335
|
+
service.allUrl = _.bind(allUrl, service, null);
|
1336
|
+
|
1337
|
+
service.stripRestangular = _.bind(stripRestangular, service);
|
1338
|
+
|
1339
|
+
service.restangularizeElement = _.bind(restangularizeElem, service);
|
1340
|
+
|
1341
|
+
service.restangularizeCollection = _.bind(restangularizeCollectionAndElements, service);
|
1342
|
+
|
1343
|
+
return service;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
return createServiceForConfiguration(globalConfiguration);
|
1347
|
+
}];
|
1348
|
+
});
|
1349
|
+
|
1350
|
+
})();
|