iugu-ux 0.8.0 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/iugu-ux/version.rb +1 -1
- data/sandbox/app/assets/javascripts/web-app/presenters/main-view.jst.eco +31 -12
- data/sandbox/app/assets/javascripts/web-app/usecode/root-view.coffee +0 -2
- data/sandbox/app/controllers/ui_library_controller.rb +0 -3
- data/sandbox/app/views/layouts/ui.html.haml +0 -1
- data/sandbox/app/views/ui_library/boiler.html.haml +2 -4
- data/sandbox/config/routes.rb +0 -1
- data/sandbox/log/development.log +20329 -0
- data/sandbox/tmp/cache/assets/BE9/020/sprockets%2Fe93a611416f4149c006c589432090903 +0 -0
- data/sandbox/tmp/cache/assets/C24/5F0/sprockets%2Fcb3028925f1090968337df085236f532 +0 -0
- data/sandbox/tmp/cache/assets/C3E/260/sprockets%2F4262142496540e6691d5bc0260a21eb5 +0 -0
- data/sandbox/tmp/cache/assets/C45/3F0/sprockets%2F0a178290fa722133d544643d13708fc6 +0 -0
- data/sandbox/tmp/cache/assets/C48/D00/sprockets%2F4a51b39094a347e3e325005c7847551c +0 -0
- data/sandbox/tmp/cache/assets/C49/3B0/sprockets%2F405c7112191eed23e8b860254281e763 +0 -0
- data/sandbox/tmp/cache/assets/C4F/3A0/sprockets%2F41918e8d7b402652a5649e4b7134d620 +0 -0
- data/sandbox/tmp/cache/assets/C53/BD0/sprockets%2F00196765c6f95bc1b670b0941172f829 +0 -0
- data/sandbox/tmp/cache/assets/C55/1B0/sprockets%2F413864885359794c0b415c5c012fd8b4 +0 -0
- data/sandbox/tmp/cache/assets/C5E/340/sprockets%2Fcaec1317015c08109f31f190314243b2 +0 -0
- data/sandbox/tmp/cache/assets/C60/360/sprockets%2Fb7a62e5a9315f80120493f865587d982 +0 -0
- data/sandbox/tmp/cache/assets/C62/3A0/sprockets%2Fad550974fd1050311169d4c5004a2e20 +0 -0
- data/sandbox/tmp/cache/assets/C6B/870/sprockets%2Fa90a46599772a03198988b6d444a678f +0 -0
- data/sandbox/tmp/cache/assets/C75/E10/sprockets%2Fb04a483530140d3348c160f58dc56d49 +0 -0
- data/sandbox/tmp/cache/assets/C7A/440/sprockets%2F3828a635611b4f542d38731a1e308f4e +0 -0
- data/sandbox/tmp/cache/assets/C7A/7B0/sprockets%2Fb5fc25d37349717a231120228a0e8d99 +0 -0
- data/sandbox/tmp/cache/assets/C7A/F30/sprockets%2F70249181577b261a3ea8851b530f1e7c +0 -0
- data/sandbox/tmp/cache/assets/C7F/4D0/sprockets%2F8e4b454014428723ac77c713ebf49613 +0 -0
- data/sandbox/tmp/cache/assets/C91/150/sprockets%2F084d158b90125d3acd60b07300f3324a +0 -0
- data/sandbox/tmp/cache/assets/CA2/760/sprockets%2Fb298c140b2372622351f1ef6b0815f3e +0 -0
- data/sandbox/tmp/cache/assets/CA3/610/sprockets%2F06183b0fa253d1afbf76a29801554914 +0 -0
- data/sandbox/tmp/cache/assets/CAB/2A0/sprockets%2F35a28a06551a3891e0582ee18e880d0d +0 -0
- data/sandbox/tmp/cache/assets/CAC/060/sprockets%2Fe72c3ba435988731c168b6441f1bc622 +0 -0
- data/sandbox/tmp/cache/assets/CB4/F00/sprockets%2Fb95d8a0b377ead5c5c59405670734228 +0 -0
- data/sandbox/tmp/cache/assets/CB9/9D0/sprockets%2F893272529e62fea11982e442c0df4c49 +0 -0
- data/sandbox/tmp/cache/assets/CBA/6A0/sprockets%2F964d3e9f13da420a6098981857d20c8b +0 -0
- data/sandbox/tmp/cache/assets/CBB/3F0/sprockets%2Feed6910664fe0a469ee6355e91212395 +0 -0
- data/sandbox/tmp/cache/assets/CBB/AA0/sprockets%2F34b613f862555697eb944a2ff6ac3526 +0 -0
- data/sandbox/tmp/cache/assets/CBB/E20/sprockets%2F00b2c2691b3a8da5553b13d123137c0c +0 -0
- data/sandbox/tmp/cache/assets/CBD/650/sprockets%2F1774801e748257cd49a236d458ce44fd +0 -0
- data/sandbox/tmp/cache/assets/CBF/870/sprockets%2F9de5a39e373d70d1455989c3a1c16676 +0 -0
- data/sandbox/tmp/cache/assets/CC7/EB0/sprockets%2F079d3b368c9e843b78c90079f26d628b +0 -0
- data/sandbox/tmp/cache/assets/CC8/510/sprockets%2F868a1670f8822e6b7847dd22e747a66f +0 -0
- data/sandbox/tmp/cache/assets/CCA/850/sprockets%2F1d05d32f046ec7313b0d3619a232d73f +0 -0
- data/sandbox/tmp/cache/assets/CCB/400/sprockets%2F1530d5680131ba31d7175dcb56e235ce +0 -0
- data/sandbox/tmp/cache/assets/CD0/590/sprockets%2F34362b49bb86e23a636817b55bab30c0 +0 -0
- data/sandbox/tmp/cache/assets/CD1/920/sprockets%2F570c0b1741c64e149720c9a70ef31a5e +0 -0
- data/sandbox/tmp/cache/assets/CD3/7E0/sprockets%2Fe1da4188365b15d4e56321fe11aa3476 +0 -0
- data/sandbox/tmp/cache/assets/CD7/0E0/sprockets%2Fb7291915fd78d50026c443b2c63fa6b0 +0 -0
- data/sandbox/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/sandbox/tmp/cache/assets/CDB/E30/sprockets%2F918458a88fec2cd01991c003b2318ab7 +0 -0
- data/sandbox/tmp/cache/assets/CDE/5C0/sprockets%2F794c70924436be60f2ec52426aa8cd61 +0 -0
- data/sandbox/tmp/cache/assets/CDF/2A0/sprockets%2Faceafc712241955028dc5b137364e869 +0 -0
- data/sandbox/tmp/cache/assets/CDF/EC0/sprockets%2Fa90760fc2f137785c7b810dcb9a40196 +0 -0
- data/sandbox/tmp/cache/assets/CE3/1C0/sprockets%2Ff617335dbdd40d03704f3d1249939f9c +0 -0
- data/sandbox/tmp/cache/assets/CE6/910/sprockets%2F4f1ef52dd511139b0d3f12f3879f6648 +0 -0
- data/sandbox/tmp/cache/assets/CE8/0F0/sprockets%2F12795deec07b2046d9467dd3f2e25809 +0 -0
- data/sandbox/tmp/cache/assets/CEA/5C0/sprockets%2Ff07ef674251629759e234ea642a3cc8e +0 -0
- data/sandbox/tmp/cache/assets/CED/340/sprockets%2F2f33f5d63e037a9f9b859f6c25139e30 +0 -0
- data/sandbox/tmp/cache/assets/CF1/CD0/sprockets%2Ff604c432d2de9f942882ecd8462578f0 +0 -0
- data/sandbox/tmp/cache/assets/CF5/E20/sprockets%2Ff31c0130a87c513e0e5ecea55135117c +0 -0
- data/sandbox/tmp/cache/assets/CFA/EE0/sprockets%2Fd95b64bc8b83485c8f3960c625885dc6 +0 -0
- data/sandbox/tmp/cache/assets/CFD/6C0/sprockets%2F1203d4bbdfe1aac02f896e2447006951 +0 -0
- data/sandbox/tmp/cache/assets/D05/8E0/sprockets%2F58046c1329c03b4cc2e5fa962f431ca8 +0 -0
- data/sandbox/tmp/cache/assets/D05/F60/sprockets%2Fb2725d240fe20257dc6a9e0b6a22399d +0 -0
- data/sandbox/tmp/cache/assets/D08/ED0/sprockets%2Fcb1aee736d3b287a872298b7741b012b +0 -0
- data/sandbox/tmp/cache/assets/D09/DB0/sprockets%2F21a7ee2fd49111e1378c6f7118fd230e +0 -0
- data/sandbox/tmp/cache/assets/D10/6D0/sprockets%2F966130263a0cbcd9c69c2f06789ad3d3 +0 -0
- data/sandbox/tmp/cache/assets/D10/8C0/sprockets%2F5d1e20d279d209b6fc1606d7de41f728 +0 -0
- data/sandbox/tmp/cache/assets/D10/E50/sprockets%2F86dbab9960f9195090301e2c42e1eeb8 +0 -0
- data/sandbox/tmp/cache/assets/D18/2F0/sprockets%2Fcc2e1640b5601b34eb61a4c333a2e31b +0 -0
- data/sandbox/tmp/cache/assets/D1A/B70/sprockets%2F47ae92dd9d034b32098b19bf8f2475a9 +0 -0
- data/sandbox/tmp/cache/assets/D1B/8C0/sprockets%2Fa2e16c5e5e97e98b526e7a6516f4622a +0 -0
- data/sandbox/tmp/cache/assets/D1E/7C0/sprockets%2Fb590b97f48766ae095ccf7b821361c6d +0 -0
- data/sandbox/tmp/cache/assets/D26/0C0/sprockets%2F44ba33f7338d8b57eb37f98e8c861e08 +0 -0
- data/sandbox/tmp/cache/assets/D2B/9B0/sprockets%2F4de45f7ee4e3076777bd571c66f8666b +0 -0
- data/sandbox/tmp/cache/assets/D2D/8C0/sprockets%2F6403fb17fb855b2dd047b010fbf8204d +0 -0
- data/sandbox/tmp/cache/assets/D2D/AF0/sprockets%2Fff24230f8cf22d156618240bb72ddb2a +0 -0
- data/sandbox/tmp/cache/assets/D2E/9D0/sprockets%2F9c0a2445ab6c0967470b5b22d4b1f8ba +0 -0
- data/sandbox/tmp/cache/assets/D2F/500/sprockets%2F4b69a31fdeabf6b46a1656d06b036043 +0 -0
- data/sandbox/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/sandbox/tmp/cache/assets/D34/280/sprockets%2F0fcf69c7e8fd9961e1158d70583e8f95 +0 -0
- data/sandbox/tmp/cache/assets/D34/3E0/sprockets%2F46a73c17c9a561115944df004dbbdd7b +0 -0
- data/sandbox/tmp/cache/assets/D35/AC0/sprockets%2F67d23b05f2a7bc455d0f5f408ca6d523 +0 -0
- data/sandbox/tmp/cache/assets/D36/930/sprockets%2Fc2a0ff7004c8ff6a483b33c8d17c2417 +0 -0
- data/sandbox/tmp/cache/assets/D37/1E0/sprockets%2Fc42800bd200fbf8edbdf9410949590a4 +0 -0
- data/sandbox/tmp/cache/assets/D37/B30/sprockets%2F9e0ec117e9064c55401b50c2abb8ff76 +0 -0
- data/sandbox/tmp/cache/assets/D39/880/sprockets%2F30ace94e10312e02fdf5d4a398393f8b +0 -0
- data/sandbox/tmp/cache/assets/D39/E50/sprockets%2F2e903f41216c9a5bfde3b77d1b9c1390 +0 -0
- data/sandbox/tmp/cache/assets/D3B/BC0/sprockets%2F19510a763bd1521ff5fc70ffe0d837d3 +0 -0
- data/sandbox/tmp/cache/assets/D3D/B80/sprockets%2F75df7c9d480cfbe1f976999e7647d771 +0 -0
- data/sandbox/tmp/cache/assets/D40/6C0/sprockets%2F5331b2ee1f23f57b9b2a96fd0a85b577 +0 -0
- data/sandbox/tmp/cache/assets/D40/8A0/sprockets%2F4483a17992b57cddb5dee15e327d30e3 +0 -0
- data/sandbox/tmp/cache/assets/D44/320/sprockets%2F27989e358a4a57b48c5e4062bff2aa4a +0 -0
- data/sandbox/tmp/cache/assets/D46/650/sprockets%2Fba1459a80d8874a816f88ffec22019ac +0 -0
- data/sandbox/tmp/cache/assets/D47/BA0/sprockets%2F6d287a845e176586f4aaa3f6b5f6ab51 +0 -0
- data/sandbox/tmp/cache/assets/D47/FD0/sprockets%2F279dd54295ff5a0e283a0e5730fff28c +0 -0
- data/sandbox/tmp/cache/assets/D48/370/sprockets%2Fb654fd37f9f63ec202a3636e29b94ef0 +0 -0
- data/sandbox/tmp/cache/assets/D4A/1A0/sprockets%2Fb746360a8b3ce79c57e74a9c15309fdd +0 -0
- data/sandbox/tmp/cache/assets/D4D/5C0/sprockets%2F66eaa47a7875ec8a24a5dbe465e75753 +0 -0
- data/sandbox/tmp/cache/assets/D4D/9B0/sprockets%2Febcc4e9d10b747864a29d16c13f5d899 +0 -0
- data/sandbox/tmp/cache/assets/D4F/810/sprockets%2Fa10070d6497ba2b4ea552d4a1bb444cb +0 -0
- data/sandbox/tmp/cache/assets/D55/310/sprockets%2F2b9be79ca64ec7d294d4825e21696ce9 +0 -0
- data/sandbox/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/sandbox/tmp/cache/assets/D5C/200/sprockets%2Fcd323e6f7545cee0b3ba1e84d7520b00 +0 -0
- data/sandbox/tmp/cache/assets/D5D/310/sprockets%2F5bbf50c40bff0ad1722051c86fe680e2 +0 -0
- data/sandbox/tmp/cache/assets/D5E/290/sprockets%2F22fb620af04e31f058ba64ec4386bb8a +0 -0
- data/sandbox/tmp/cache/assets/D62/490/sprockets%2Fd7c71cd09b0f551a237150dae69ca93a +0 -0
- data/sandbox/tmp/cache/assets/D62/690/sprockets%2F11532c31a6be258097db31bbeb9ff35d +0 -0
- data/sandbox/tmp/cache/assets/D66/BB0/sprockets%2F190ee4571dbbf206b6b26007fd9be9a2 +0 -0
- data/sandbox/tmp/cache/assets/D6A/ED0/sprockets%2Ff5d445fff783322a14283beb4eb5bc33 +0 -0
- data/sandbox/tmp/cache/assets/D6B/0F0/sprockets%2F3609df3f470bd24af26a51de476cef05 +0 -0
- data/sandbox/tmp/cache/assets/D6C/110/sprockets%2F2d5d9cd3d0adf965d07e64a3049d106e +0 -0
- data/sandbox/tmp/cache/assets/D6D/AA0/sprockets%2F1cb4a75912d38d0bdde6ee6770644d0f +0 -0
- data/sandbox/tmp/cache/assets/D6E/AE0/sprockets%2Fe193ea7b03f186ad2a9515fc78fa8c21 +0 -0
- data/sandbox/tmp/cache/assets/D6F/690/sprockets%2F1aa0aa2e0ecc490b1b0ede43013535c1 +0 -0
- data/sandbox/tmp/cache/assets/D70/320/sprockets%2Fb81a3eab4ea93cf21fd7585436b8a169 +0 -0
- data/sandbox/tmp/cache/assets/D70/5D0/sprockets%2F2ff973bae9120e8358ccbaa6395c2b19 +0 -0
- data/sandbox/tmp/cache/assets/D72/250/sprockets%2F68bd0a6d091ef3ba0a64b9762794d6de +0 -0
- data/sandbox/tmp/cache/assets/D72/680/sprockets%2F56c41c78c49d45b9ca0c358adea917f0 +0 -0
- data/sandbox/tmp/cache/assets/D74/0A0/sprockets%2Fc1392b79af6b88250b634479cbf2bcfc +0 -0
- data/sandbox/tmp/cache/assets/D79/5A0/sprockets%2Feb399a6f39a8dcd0bf011768e7153d8d +0 -0
- data/sandbox/tmp/cache/assets/D7A/D40/sprockets%2F4d2bc08f2787a3870ff93e0e0f7bc67e +0 -0
- data/sandbox/tmp/cache/assets/D7C/270/sprockets%2Fc15bcc081286a12c1751bfad1ac2f2a4 +0 -0
- data/sandbox/tmp/cache/assets/D7D/2C0/sprockets%2Fdc76b19d5f8ce4e6e4e9c735c223091f +0 -0
- data/sandbox/tmp/cache/assets/D88/B70/sprockets%2F9b378be843af782b809c5ce3d6f6d47f +0 -0
- data/sandbox/tmp/cache/assets/D89/670/sprockets%2Fbf838afe9adf908d9ec59bc552833285 +0 -0
- data/sandbox/tmp/cache/assets/D8C/D40/sprockets%2Fc4a00154a0e1c15a495ce4d49c9f0ccf +0 -0
- data/sandbox/tmp/cache/assets/D96/460/sprockets%2F510545dac5cc61f17bc4d1e8e740fec5 +0 -0
- data/sandbox/tmp/cache/assets/D96/940/sprockets%2F6a2c3af22b173eb975f382b4cdcd8c41 +0 -0
- data/sandbox/tmp/cache/assets/D96/E90/sprockets%2F0d5f451deca7e6811663f30afc3a4fd4 +0 -0
- data/sandbox/tmp/cache/assets/D97/180/sprockets%2F933323d1c368cfeda7a0cacdbd295933 +0 -0
- data/sandbox/tmp/cache/assets/D9E/000/sprockets%2F1e365d6ecdad349c6f900a3aa829cf18 +0 -0
- data/sandbox/tmp/cache/assets/D9F/020/sprockets%2Fd21cfdfa8182a8866e0ba904ef6561ea +0 -0
- data/sandbox/tmp/cache/assets/DA5/EA0/sprockets%2Fc2e6b41187b059dbddd8dbd7cb884482 +0 -0
- data/sandbox/tmp/cache/assets/DA7/DE0/sprockets%2Ff022dcf0c3c5fd7de3989f600dc7585c +0 -0
- data/sandbox/tmp/cache/assets/DA9/420/sprockets%2F4be564f02ffc16e32df33e92e43fb8f9 +0 -0
- data/sandbox/tmp/cache/assets/DAD/190/sprockets%2Fbee62a5d7a8cd35a33763f1cd879de59 +0 -0
- data/sandbox/tmp/cache/assets/DB5/EC0/sprockets%2Fde17edd0f2eca28280c1a27ac5c510c3 +0 -0
- data/sandbox/tmp/cache/assets/DBE/5E0/sprockets%2F7663abb4baaadfc7e6a48f1150f32b62 +0 -0
- data/sandbox/tmp/cache/assets/DBE/A00/sprockets%2F266ad056a1ae59c1b2934fcd2cad6cf0 +0 -0
- data/sandbox/tmp/cache/assets/DCA/FD0/sprockets%2F0b59a77adfc61bb863e708ba262ce6bd +0 -0
- data/sandbox/tmp/cache/assets/DCB/100/sprockets%2Fd313bd7561b538fb7f2c4ab89dba5b7b +0 -0
- data/sandbox/tmp/cache/assets/DCD/930/sprockets%2F6fd2f59e45a7f3c88a183ee00d1cccd0 +0 -0
- data/sandbox/tmp/cache/assets/DD0/140/sprockets%2Ff9c3eeef5e04c483a3d2e3fbf458a413 +0 -0
- data/sandbox/tmp/cache/assets/DD5/040/sprockets%2F8b8bc1dd8d844edda81c52b7bd29a926 +0 -0
- data/sandbox/tmp/cache/assets/DD6/B70/sprockets%2F2f433efcb60c276ccd93cfdce59687a1 +0 -0
- data/sandbox/tmp/cache/assets/DD7/9B0/sprockets%2F9f2c0826bd7ae7b745ae8da6db48c26e +0 -0
- data/sandbox/tmp/cache/assets/DD8/3B0/sprockets%2Fef4ddeef4487be0bf8c6412714f61e8a +0 -0
- data/sandbox/tmp/cache/assets/DE5/390/sprockets%2F24a1cda6893cebd53997dc859def67cd +0 -0
- data/sandbox/tmp/cache/assets/DF5/EF0/sprockets%2Fd1e83d1a6f55fafac76b4a2ac8541fd1 +0 -0
- data/sandbox/tmp/cache/assets/DFC/890/sprockets%2F2a2c6a1ea98a0cd7b5f7ff4ef7264b3c +0 -0
- data/sandbox/tmp/cache/assets/E05/2E0/sprockets%2F92ecbfa92baf6e394ce6c39d731b7cd2 +0 -0
- data/sandbox/tmp/cache/assets/E12/710/sprockets%2F7e9ee2069eafc7ddd7aff731dc9186d2 +0 -0
- data/sandbox/tmp/cache/assets/E38/420/sprockets%2Fd5e6ba266c8ebddcbf04b3099cf747ff +0 -0
- data/sandbox/tmp/cache/assets/E3F/FE0/sprockets%2Fbbbb6f82edbdac31a0c71ce0b04718ac +0 -0
- data/sandbox/tmp/cache/assets/E40/840/sprockets%2F0b2c9ee1f1fe00aad3bec06cbd08cd15 +0 -0
- data/sandbox/tmp/cache/assets/EC9/D10/sprockets%2F8dfe5ddb2cf1a7f77098fd9eb4ddbcab +0 -0
- data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/components.sassc +0 -0
- data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/reset.sassc +0 -0
- data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/variables.sassc +0 -0
- data/sandbox/tmp/cache/sass/e18337f0c19dfad20daa699fa9a096f70c37cd66/experiment.sassc +0 -0
- data/vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffee +21 -0
- data/vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee +65 -0
- data/vendor/assets/javascripts/iugu-ux/components/iugu-ux-components.js +7 -1
- data/vendor/assets/javascripts/iugu-ux/components/iugu-ux-main.js.coffee +4 -2
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-alert.jst.eco +6 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-dataset-record.jst.eco +6 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-dataset.jst.eco +2 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-navigator.jst.eco +6 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-paginator.jst.eco +19 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-responsive-box.jst.eco +2 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-scrollable-container.jst.eco +4 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search-filter.jst.eco +15 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search-range.jst.eco +5 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search.jst.eco +3 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-table-row.jst.eco +3 -0
- data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-table.jst.eco +19 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/// +83 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-alert.js.coffee +17 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-base.js.coffee +83 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-dataset-record.js.coffee +17 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-dataset.js.coffee +47 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-navigator.js.coffee +47 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-paginator.js.coffee +58 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-responsive-box.js.coffee +83 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-scrollable-content.js.coffee +13 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee +55 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-range.js.coffee +35 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search.js.coffee +28 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-table.js.coffee +39 -0
- data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee +78 -0
- data/vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee +52 -0
- data/vendor/assets/javascripts/iugu-ux/iugu-ux.js +0 -1
- data/vendor/assets/javascripts/iugu-ux/web-app.js +5 -1
- data/vendor/assets/javascripts/vendor.js +5 -0
- data/vendor/assets/javascripts/vendor/async.js +700 -0
- data/vendor/assets/javascripts/vendor/backbone.paginator.js +833 -0
- data/vendor/assets/javascripts/vendor/backbone.validation.js +538 -0
- data/vendor/assets/javascripts/vendor/rivets.js +583 -0
- data/vendor/assets/javascripts/vendor/tasks.js.coffee +16 -0
- data/vendor/assets/javascripts/web-app/config.js.erb +2 -0
- data/vendor/assets/javascripts/web-app/helpers.coffee +5 -0
- data/vendor/assets/stylesheets/iugu-ux/components.sass +186 -0
- data/vendor/assets/stylesheets/iugu-ux/reset.sass +5 -0
- data/vendor/assets/stylesheets/iugu-ux/variables.sass +28 -0
- metadata +260 -44
- data/sandbox/app/assets/stylesheets/application.css +0 -3
- data/sandbox/app/assets/stylesheets/default-sprites.sass +0 -12
- data/sandbox/app/assets/stylesheets/experiment.sass +0 -181
- data/sandbox/app/assets/stylesheets/mq-styles.sass +0 -50
- data/sandbox/app/assets/stylesheets/mqtest.css +0 -6
- data/sandbox/app/assets/stylesheets/sandbox-sprites.css +0 -6
- data/sandbox/app/views/ui_library/mediaquery.html.haml +0 -5
@@ -0,0 +1,538 @@
|
|
1
|
+
Backbone.Validation = (function(_){
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// Default options
|
5
|
+
// ---------------
|
6
|
+
|
7
|
+
var defaultOptions = {
|
8
|
+
forceUpdate: false,
|
9
|
+
selector: 'name',
|
10
|
+
labelFormatter: 'sentenceCase',
|
11
|
+
valid: Function.prototype,
|
12
|
+
invalid: Function.prototype
|
13
|
+
};
|
14
|
+
|
15
|
+
|
16
|
+
// Validation
|
17
|
+
// ----------
|
18
|
+
|
19
|
+
var Validation = (function(){
|
20
|
+
|
21
|
+
// Returns an object with undefined properties for all
|
22
|
+
// attributes on the model that has defined one or more
|
23
|
+
// validation rules.
|
24
|
+
var getValidatedAttrs = function(model) {
|
25
|
+
return _.reduce(_.keys(model.validation || {}), function(memo, key) {
|
26
|
+
memo[key] = void 0;
|
27
|
+
return memo;
|
28
|
+
}, {});
|
29
|
+
};
|
30
|
+
|
31
|
+
// Looks on the model for validations for a specified
|
32
|
+
// attribute. Returns an array of any validators defined,
|
33
|
+
// or an empty array if none is defined.
|
34
|
+
var getValidators = function(model, attr) {
|
35
|
+
var attrValidationSet = model.validation ? model.validation[attr] || {} : {};
|
36
|
+
|
37
|
+
// If the validator is a function or a string, wrap it in a function validator
|
38
|
+
if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) {
|
39
|
+
attrValidationSet = {
|
40
|
+
fn: attrValidationSet
|
41
|
+
};
|
42
|
+
}
|
43
|
+
|
44
|
+
// Stick the validator object into an array
|
45
|
+
if(!_.isArray(attrValidationSet)) {
|
46
|
+
attrValidationSet = [attrValidationSet];
|
47
|
+
}
|
48
|
+
|
49
|
+
// Reduces the array of validators into a new array with objects
|
50
|
+
// with a validation method to call, the value to validate against
|
51
|
+
// and the specified error message, if any
|
52
|
+
return _.reduce(attrValidationSet, function(memo, attrValidation) {
|
53
|
+
_.each(_.without(_.keys(attrValidation), 'msg'), function(validator) {
|
54
|
+
memo.push({
|
55
|
+
fn: defaultValidators[validator],
|
56
|
+
val: attrValidation[validator],
|
57
|
+
msg: attrValidation.msg
|
58
|
+
});
|
59
|
+
});
|
60
|
+
return memo;
|
61
|
+
}, []);
|
62
|
+
};
|
63
|
+
|
64
|
+
// Validates an attribute against all validators defined
|
65
|
+
// for that attribute. If one or more errors are found,
|
66
|
+
// the first error message is returned.
|
67
|
+
// If the attribute is valid, an empty string is returned.
|
68
|
+
var validateAttr = function(model, attr, value, computed) {
|
69
|
+
// Reduces the array of validators to an error message by
|
70
|
+
// applying all the validators and returning the first error
|
71
|
+
// message, if any.
|
72
|
+
return _.reduce(getValidators(model, attr), function(memo, validator){
|
73
|
+
var result = validator.fn.call(defaultValidators, value, attr, validator.val, model, computed);
|
74
|
+
if(result === false || memo === false) {
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
if (result && !memo) {
|
78
|
+
return validator.msg || result;
|
79
|
+
}
|
80
|
+
return memo;
|
81
|
+
}, '');
|
82
|
+
};
|
83
|
+
|
84
|
+
// Loops through the model's attributes and validates them all.
|
85
|
+
// Returns and object containing names of invalid attributes
|
86
|
+
// as well as error messages.
|
87
|
+
var validateModel = function(model, attrs) {
|
88
|
+
var error, attr,
|
89
|
+
invalidAttrs = {},
|
90
|
+
isValid = true,
|
91
|
+
computed = _.clone(attrs);
|
92
|
+
|
93
|
+
for (attr in attrs) {
|
94
|
+
error = validateAttr(model, attr, attrs[attr], computed);
|
95
|
+
if (error) {
|
96
|
+
invalidAttrs[attr] = error;
|
97
|
+
isValid = false;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
return {
|
102
|
+
invalidAttrs: invalidAttrs,
|
103
|
+
isValid: isValid
|
104
|
+
};
|
105
|
+
};
|
106
|
+
|
107
|
+
// Contains the methods that are mixed in on the model when binding
|
108
|
+
var mixin = function(view, options) {
|
109
|
+
return {
|
110
|
+
|
111
|
+
// Check whether or not a value passes validation
|
112
|
+
// without updating the model
|
113
|
+
preValidate: function(attr, value) {
|
114
|
+
return validateAttr(this, attr, value, _.extend({}, this.attributes));
|
115
|
+
},
|
116
|
+
|
117
|
+
// Check to see if an attribute, an array of attributes or the
|
118
|
+
// entire model is valid. Passing true will force a validation
|
119
|
+
// of the model.
|
120
|
+
isValid: function(option) {
|
121
|
+
if(_.isString(option)){
|
122
|
+
return !validateAttr(this, option, this.get(option), _.extend({}, this.attributes));
|
123
|
+
}
|
124
|
+
if(_.isArray(option)){
|
125
|
+
for (var i = 0; i < option.length; i++) {
|
126
|
+
if(validateAttr(this, option[i], this.get(option[i]), _.extend({}, this.attributes))){
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
if(option === true) {
|
133
|
+
this.validate();
|
134
|
+
}
|
135
|
+
return this.validation ? this._isValid : true;
|
136
|
+
},
|
137
|
+
|
138
|
+
// This is called by Backbone when it needs to perform validation.
|
139
|
+
// You can call it manually without any parameters to validate the
|
140
|
+
// entire model.
|
141
|
+
validate: function(attrs, setOptions){
|
142
|
+
var model = this,
|
143
|
+
validateAll = !attrs,
|
144
|
+
opt = _.extend({}, options, setOptions),
|
145
|
+
allAttrs = _.extend(getValidatedAttrs(model), model.attributes, attrs),
|
146
|
+
changedAttrs = attrs || allAttrs,
|
147
|
+
result = validateModel(model, allAttrs);
|
148
|
+
|
149
|
+
model._isValid = result.isValid;
|
150
|
+
|
151
|
+
// After validation is performed, loop through all changed attributes
|
152
|
+
// and call either the valid or invalid callback so the view is updated.
|
153
|
+
for(var attr in allAttrs) {
|
154
|
+
var invalid = result.invalidAttrs.hasOwnProperty(attr),
|
155
|
+
changed = changedAttrs.hasOwnProperty(attr);
|
156
|
+
if(invalid && (changed || validateAll)){
|
157
|
+
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
|
158
|
+
}
|
159
|
+
if(!invalid){
|
160
|
+
opt.valid(view, attr, opt.selector);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
// Trigger validated events.
|
165
|
+
// Need to defer this so the model is actually updated before
|
166
|
+
// the event is triggered.
|
167
|
+
_.defer(function() {
|
168
|
+
model.trigger('validated', model._isValid, model, result.invalidAttrs);
|
169
|
+
model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
|
170
|
+
});
|
171
|
+
|
172
|
+
// Return any error messages to Backbone, unless the forceUpdate flag is set.
|
173
|
+
// Then we do not return anything and fools Backbone to believe the validation was
|
174
|
+
// a success. That way Backbone will update the model regardless.
|
175
|
+
if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
|
176
|
+
return result.invalidAttrs;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
};
|
180
|
+
};
|
181
|
+
|
182
|
+
// Helper to mix in validation on a model
|
183
|
+
var bindModel = function(view, model, options) {
|
184
|
+
_.extend(model, mixin(view, options));
|
185
|
+
};
|
186
|
+
|
187
|
+
// Removes the methods added to a model
|
188
|
+
var unbindModel = function(model) {
|
189
|
+
delete model.validate;
|
190
|
+
delete model.preValidate;
|
191
|
+
delete model.isValid;
|
192
|
+
};
|
193
|
+
|
194
|
+
// Mix in validation on a model whenever a model is
|
195
|
+
// added to a collection
|
196
|
+
var collectionAdd = function(model) {
|
197
|
+
bindModel(this.view, model, this.options);
|
198
|
+
};
|
199
|
+
|
200
|
+
// Remove validation from a model whenever a model is
|
201
|
+
// removed from a collection
|
202
|
+
var collectionRemove = function(model) {
|
203
|
+
unbindModel(model);
|
204
|
+
};
|
205
|
+
|
206
|
+
// Returns the public methods on Backbone.Validation
|
207
|
+
return {
|
208
|
+
|
209
|
+
// Current version of the library
|
210
|
+
version: '0.6.2',
|
211
|
+
|
212
|
+
// Called to configure the default options
|
213
|
+
configure: function(options) {
|
214
|
+
_.extend(defaultOptions, options);
|
215
|
+
},
|
216
|
+
|
217
|
+
// Hooks up validation on a view with a model
|
218
|
+
// or collection
|
219
|
+
bind: function(view, options) {
|
220
|
+
var model = view.model,
|
221
|
+
collection = view.collection;
|
222
|
+
options = _.extend({}, defaultOptions, defaultCallbacks, options);
|
223
|
+
|
224
|
+
if(typeof model === 'undefined' && typeof collection === 'undefined'){
|
225
|
+
throw 'Before you execute the binding your view must have a model or a collection.\n' +
|
226
|
+
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
|
227
|
+
}
|
228
|
+
|
229
|
+
if(model) {
|
230
|
+
bindModel(view, model, options);
|
231
|
+
}
|
232
|
+
if(collection) {
|
233
|
+
collection.each(function(model){
|
234
|
+
bindModel(view, model, options);
|
235
|
+
});
|
236
|
+
collection.bind('add', collectionAdd, {view: view, options: options});
|
237
|
+
collection.bind('remove', collectionRemove);
|
238
|
+
}
|
239
|
+
},
|
240
|
+
|
241
|
+
// Removes validation from a view with a model
|
242
|
+
// or collection
|
243
|
+
unbind: function(view) {
|
244
|
+
var model = view.model,
|
245
|
+
collection = view.collection;
|
246
|
+
|
247
|
+
if(model) {
|
248
|
+
unbindModel(view.model);
|
249
|
+
}
|
250
|
+
if(collection) {
|
251
|
+
collection.each(function(model){
|
252
|
+
unbindModel(model);
|
253
|
+
});
|
254
|
+
collection.unbind('add', collectionAdd);
|
255
|
+
collection.unbind('remove', collectionRemove);
|
256
|
+
}
|
257
|
+
},
|
258
|
+
|
259
|
+
// Used to extend the Backbone.Model.prototype
|
260
|
+
// with validation
|
261
|
+
mixin: mixin(null, defaultOptions)
|
262
|
+
};
|
263
|
+
}());
|
264
|
+
|
265
|
+
|
266
|
+
// Callbacks
|
267
|
+
// ---------
|
268
|
+
|
269
|
+
var defaultCallbacks = Validation.callbacks = {
|
270
|
+
|
271
|
+
// Gets called when a previously invalid field in the
|
272
|
+
// view becomes valid. Removes any error message.
|
273
|
+
// Should be overridden with custom functionality.
|
274
|
+
valid: function(view, attr, selector) {
|
275
|
+
view.$('[' + selector + '~=' + attr + ']')
|
276
|
+
.removeClass('invalid')
|
277
|
+
.removeAttr('data-error');
|
278
|
+
},
|
279
|
+
|
280
|
+
// Gets called when a field in the view becomes invalid.
|
281
|
+
// Adds a error message.
|
282
|
+
// Should be overridden with custom functionality.
|
283
|
+
invalid: function(view, attr, error, selector) {
|
284
|
+
view.$('[' + selector + '~=' + attr + ']')
|
285
|
+
.addClass('invalid')
|
286
|
+
.attr('data-error', error);
|
287
|
+
}
|
288
|
+
};
|
289
|
+
|
290
|
+
|
291
|
+
// Patterns
|
292
|
+
// --------
|
293
|
+
|
294
|
+
var defaultPatterns = Validation.patterns = {
|
295
|
+
// Matches any digit(s) (i.e. 0-9)
|
296
|
+
digits: /^\d+$/,
|
297
|
+
|
298
|
+
// Matched any number (e.g. 100.000)
|
299
|
+
number: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
|
300
|
+
|
301
|
+
// Matches a valid email address (e.g. mail@example.com)
|
302
|
+
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
|
303
|
+
|
304
|
+
// Mathes any valid url (e.g. http://www.xample.com)
|
305
|
+
url: /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
|
306
|
+
};
|
307
|
+
|
308
|
+
|
309
|
+
// Error messages
|
310
|
+
// --------------
|
311
|
+
|
312
|
+
// Error message for the build in validators.
|
313
|
+
// {x} gets swapped out with arguments form the validator.
|
314
|
+
var defaultMessages = Validation.messages = {
|
315
|
+
required: '{0} is required',
|
316
|
+
acceptance: '{0} must be accepted',
|
317
|
+
min: '{0} must be greater than or equal to {1}',
|
318
|
+
max: '{0} must be less than or equal to {1}',
|
319
|
+
range: '{0} must be between {1} and {2}',
|
320
|
+
length: '{0} must be {1} characters',
|
321
|
+
minLength: '{0} must be at least {1} characters',
|
322
|
+
maxLength: '{0} must be at most {1} characters',
|
323
|
+
rangeLength: '{0} must be between {1} and {2} characters',
|
324
|
+
oneOf: '{0} must be one of: {1}',
|
325
|
+
equalTo: '{0} must be the same as {1}',
|
326
|
+
pattern: '{0} must be a valid {1}'
|
327
|
+
};
|
328
|
+
|
329
|
+
// Label formatters
|
330
|
+
// ----------------
|
331
|
+
|
332
|
+
// Label formatters are used to convert the attribute name
|
333
|
+
// to a more human friendly label when using the built in
|
334
|
+
// error messages.
|
335
|
+
// Configure which one to use with a call to
|
336
|
+
//
|
337
|
+
// Backbone.Validation.configure({
|
338
|
+
// labelFormatter: 'label'
|
339
|
+
// });
|
340
|
+
var defaultLabelFormatters = Validation.labelFormatters = {
|
341
|
+
|
342
|
+
// Returns the attribute name with applying any formatting
|
343
|
+
none: function(attrName) {
|
344
|
+
return attrName;
|
345
|
+
},
|
346
|
+
|
347
|
+
// Converts attributeName or attribute_name to Attribute name
|
348
|
+
sentenceCase: function(attrName) {
|
349
|
+
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
|
350
|
+
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
|
351
|
+
}).replace('_', ' ');
|
352
|
+
},
|
353
|
+
|
354
|
+
// Looks for a label configured on the model and returns it
|
355
|
+
//
|
356
|
+
// var Model = Backbone.Model.extend({
|
357
|
+
// validation: {
|
358
|
+
// someAttribute: {
|
359
|
+
// required: true
|
360
|
+
// }
|
361
|
+
// },
|
362
|
+
//
|
363
|
+
// labels: {
|
364
|
+
// someAttribute: 'Custom label'
|
365
|
+
// }
|
366
|
+
// });
|
367
|
+
label: function(attrName, model) {
|
368
|
+
return model.labels[attrName] || defaultLabelFormatters.sentenceCase(attrName, model);
|
369
|
+
}
|
370
|
+
};
|
371
|
+
|
372
|
+
// Built in validators
|
373
|
+
// -------------------
|
374
|
+
|
375
|
+
var defaultValidators = Validation.validators = (function(){
|
376
|
+
// Use native trim when defined
|
377
|
+
var trim = String.prototype.trim ?
|
378
|
+
function(text) {
|
379
|
+
return text === null ? '' : String.prototype.trim.call(text);
|
380
|
+
} :
|
381
|
+
function(text) {
|
382
|
+
var trimLeft = /^\s+/,
|
383
|
+
trimRight = /\s+$/;
|
384
|
+
|
385
|
+
return text === null ? '' : text.toString().replace(trimLeft, '').replace(trimRight, '');
|
386
|
+
};
|
387
|
+
|
388
|
+
// Uses the configured label formatter to format the attribute name
|
389
|
+
// to make it more readable for the user
|
390
|
+
var formatLabel = function(attrName, model) {
|
391
|
+
return defaultLabelFormatters[defaultOptions.labelFormatter](attrName, model);
|
392
|
+
};
|
393
|
+
|
394
|
+
// Replaces nummeric placeholders like {0} in a string with arguments
|
395
|
+
// passed to the function
|
396
|
+
var format = function() {
|
397
|
+
var args = Array.prototype.slice.call(arguments);
|
398
|
+
var text = args.shift();
|
399
|
+
return text.replace(/\{(\d+)\}/g, function(match, number) {
|
400
|
+
return typeof args[number] !== 'undefined' ? args[number] : match;
|
401
|
+
});
|
402
|
+
};
|
403
|
+
|
404
|
+
// Determines whether or not a value is a number
|
405
|
+
var isNumber = function(value){
|
406
|
+
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
|
407
|
+
};
|
408
|
+
|
409
|
+
// Determines whether or not not a value is empty
|
410
|
+
var hasValue = function(value) {
|
411
|
+
return !(_.isNull(value) || _.isUndefined(value) || (_.isString(value) && trim(value) === ''));
|
412
|
+
};
|
413
|
+
|
414
|
+
return {
|
415
|
+
// Function validator
|
416
|
+
// Lets you implement a custom function used for validation
|
417
|
+
fn: function(value, attr, fn, model, computed) {
|
418
|
+
if(_.isString(fn)){
|
419
|
+
fn = model[fn];
|
420
|
+
}
|
421
|
+
return fn.call(model, value, attr, computed);
|
422
|
+
},
|
423
|
+
|
424
|
+
// Required validator
|
425
|
+
// Validates if the attribute is required or not
|
426
|
+
required: function(value, attr, required, model, computed) {
|
427
|
+
var isRequired = _.isFunction(required) ? required.call(model, value, attr, computed) : required;
|
428
|
+
if(!isRequired && !hasValue(value)) {
|
429
|
+
return false; // overrides all other validators
|
430
|
+
}
|
431
|
+
if (isRequired && !hasValue(value)) {
|
432
|
+
return format(defaultMessages.required, formatLabel(attr, model));
|
433
|
+
}
|
434
|
+
},
|
435
|
+
|
436
|
+
// Acceptance validator
|
437
|
+
// Validates that something has to be accepted, e.g. terms of use
|
438
|
+
// `true` or 'true' are valid
|
439
|
+
acceptance: function(value, attr, accept, model) {
|
440
|
+
if(value !== 'true' && (!_.isBoolean(value) || value === false)) {
|
441
|
+
return format(defaultMessages.acceptance, formatLabel(attr, model));
|
442
|
+
}
|
443
|
+
},
|
444
|
+
|
445
|
+
// Min validator
|
446
|
+
// Validates that the value has to be a number and equal to or greater than
|
447
|
+
// the min value specified
|
448
|
+
min: function(value, attr, minValue, model) {
|
449
|
+
if (!isNumber(value) || value < minValue) {
|
450
|
+
return format(defaultMessages.min, formatLabel(attr, model), minValue);
|
451
|
+
}
|
452
|
+
},
|
453
|
+
|
454
|
+
// Max validator
|
455
|
+
// Validates that the value has to be a number and equal to or less than
|
456
|
+
// the max value specified
|
457
|
+
max: function(value, attr, maxValue, model) {
|
458
|
+
if (!isNumber(value) || value > maxValue) {
|
459
|
+
return format(defaultMessages.max, formatLabel(attr, model), maxValue);
|
460
|
+
}
|
461
|
+
},
|
462
|
+
|
463
|
+
// Range validator
|
464
|
+
// Validates that the value has to be a number and equal to or between
|
465
|
+
// the two numbers specified
|
466
|
+
range: function(value, attr, range, model) {
|
467
|
+
if(!isNumber(value) || value < range[0] || value > range[1]) {
|
468
|
+
return format(defaultMessages.range, formatLabel(attr, model), range[0], range[1]);
|
469
|
+
}
|
470
|
+
},
|
471
|
+
|
472
|
+
// Length validator
|
473
|
+
// Validates that the value has to be a string with length equal to
|
474
|
+
// the length value specified
|
475
|
+
length: function(value, attr, length, model) {
|
476
|
+
if (!hasValue(value) || trim(value).length !== length) {
|
477
|
+
return format(defaultMessages.length, formatLabel(attr, model), length);
|
478
|
+
}
|
479
|
+
},
|
480
|
+
|
481
|
+
// Min length validator
|
482
|
+
// Validates that the value has to be a string with length equal to or greater than
|
483
|
+
// the min length value specified
|
484
|
+
minLength: function(value, attr, minLength, model) {
|
485
|
+
if (!hasValue(value) || trim(value).length < minLength) {
|
486
|
+
return format(defaultMessages.minLength, formatLabel(attr, model), minLength);
|
487
|
+
}
|
488
|
+
},
|
489
|
+
|
490
|
+
// Max length validator
|
491
|
+
// Validates that the value has to be a string with length equal to or less than
|
492
|
+
// the max length value specified
|
493
|
+
maxLength: function(value, attr, maxLength, model) {
|
494
|
+
if (!hasValue(value) || trim(value).length > maxLength) {
|
495
|
+
return format(defaultMessages.maxLength, formatLabel(attr, model), maxLength);
|
496
|
+
}
|
497
|
+
},
|
498
|
+
|
499
|
+
// Range length validator
|
500
|
+
// Validates that the value has to be a string and equal to or between
|
501
|
+
// the two numbers specified
|
502
|
+
rangeLength: function(value, attr, range, model) {
|
503
|
+
if(!hasValue(value) || trim(value).length < range[0] || trim(value).length > range[1]) {
|
504
|
+
return format(defaultMessages.rangeLength, formatLabel(attr, model), range[0], range[1]);
|
505
|
+
}
|
506
|
+
},
|
507
|
+
|
508
|
+
// One of validator
|
509
|
+
// Validates that the value has to be equal to one of the elements in
|
510
|
+
// the specified array. Case sensitive matching
|
511
|
+
oneOf: function(value, attr, values, model) {
|
512
|
+
if(!_.include(values, value)){
|
513
|
+
return format(defaultMessages.oneOf, formatLabel(attr, model), values.join(', '));
|
514
|
+
}
|
515
|
+
},
|
516
|
+
|
517
|
+
// Equal to validator
|
518
|
+
// Validates that the value has to be equal to the value of the attribute
|
519
|
+
// with the name specified
|
520
|
+
equalTo: function(value, attr, equalTo, model, computed) {
|
521
|
+
if(value !== computed[equalTo]) {
|
522
|
+
return format(defaultMessages.equalTo, formatLabel(attr, model), formatLabel(equalTo, model));
|
523
|
+
}
|
524
|
+
},
|
525
|
+
|
526
|
+
// Pattern validator
|
527
|
+
// Validates that the value has to match the pattern specified.
|
528
|
+
// Can be a regular expression or the name of one of the built in patterns
|
529
|
+
pattern: function(value, attr, pattern, model) {
|
530
|
+
if (!hasValue(value) || !value.toString().match(defaultPatterns[pattern] || pattern)) {
|
531
|
+
return format(defaultMessages.pattern, formatLabel(attr, model), pattern);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
};
|
535
|
+
}());
|
536
|
+
|
537
|
+
return Validation;
|
538
|
+
}(_));
|