abstracted 0.0.6 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -8
- data/app/assets/javascripts/abstract_resources.js +29 -25
- data/app/assets/javascripts/crud.js.coffee +174 -29
- data/app/assets/javascripts/initializers.js.coffee +403 -58
- data/app/assets/javascripts/pagescrolling.js.coffee +92 -0
- data/app/assets/stylesheets/abstract_resources.css +5 -0
- data/app/assets/stylesheets/scaffold.css +4 -2
- data/app/assets/stylesheets/selectize.css.scss +0 -0
- data/app/controllers/abstract_resources_controller.rb +473 -134
- data/app/controllers/application_controller.rb +22 -7
- data/app/helpers/abstract_resources_helper.rb +515 -9
- data/app/helpers/fab_button_helper.rb +82 -0
- data/app/models/abstract_resource.rb +141 -89
- data/app/models/ancestry_abstract_resource.rb +27 -0
- data/app/models/concerns/roleable.rb +1 -1
- data/app/policies/abstract_resource_policy.rb +25 -0
- data/app/views/abstract_resources/_title.html.haml +2 -0
- data/app/views/abstract_resources/activate.html.haml +5 -0
- data/app/views/abstract_resources/attach.html.haml +6 -0
- data/app/views/abstract_resources/deactivate.html.haml +5 -0
- data/app/views/abstract_resources/defer.html.haml +5 -0
- data/app/views/abstract_resources/destroy.js.haml +2 -1
- data/app/views/abstract_resources/detach.html.haml +5 -0
- data/app/views/abstract_resources/edit.html.haml +4 -9
- data/app/views/abstract_resources/error.html.haml +2 -0
- data/app/views/abstract_resources/error.js.haml +2 -0
- data/app/views/abstract_resources/index.html.haml +27 -0
- data/app/views/abstract_resources/index.js.haml +2 -0
- data/app/views/abstract_resources/new.html.haml +4 -10
- data/app/views/abstract_resources/prefer.html.haml +5 -0
- data/app/views/abstract_resources/print.html.haml +2 -0
- data/app/views/abstract_resources/print.js.haml +2 -0
- data/app/views/abstract_resources/show.html.haml +5 -11
- data/app/views/layouts/_messages.html.haml +1 -0
- data/app/views/layouts/_navigation.html.haml +13 -0
- data/bower.json +34 -0
- data/config/initializers/exception.rb +19 -0
- data/config/initializers/pundit.rb +22 -0
- data/config/routes.rb +24 -0
- data/lib/abstracted.rb +3 -0
- data/lib/abstracted/version.rb +1 -1
- data/lib/abstracted_responder.rb +1 -0
- data/lib/exceptions.rb +61 -0
- data/vendor/assets/components/jquery/.bower.json +38 -0
- data/vendor/assets/components/jquery/MIT-LICENSE.txt +21 -0
- data/vendor/assets/components/jquery/bower.json +28 -0
- data/vendor/assets/components/jquery/dist/jquery.js +9210 -0
- data/vendor/assets/components/jquery/dist/jquery.min.js +5 -0
- data/vendor/assets/components/jquery/dist/jquery.min.map +1 -0
- data/vendor/assets/components/jquery/src/ajax.js +786 -0
- data/vendor/assets/components/jquery/src/ajax/jsonp.js +89 -0
- data/vendor/assets/components/jquery/src/ajax/load.js +75 -0
- data/vendor/assets/components/jquery/src/ajax/parseJSON.js +13 -0
- data/vendor/assets/components/jquery/src/ajax/parseXML.js +28 -0
- data/vendor/assets/components/jquery/src/ajax/script.js +64 -0
- data/vendor/assets/components/jquery/src/ajax/var/nonce.js +5 -0
- data/vendor/assets/components/jquery/src/ajax/var/rquery.js +3 -0
- data/vendor/assets/components/jquery/src/ajax/xhr.js +136 -0
- data/vendor/assets/components/jquery/src/attributes.js +11 -0
- data/vendor/assets/components/jquery/src/attributes/attr.js +141 -0
- data/vendor/assets/components/jquery/src/attributes/classes.js +158 -0
- data/vendor/assets/components/jquery/src/attributes/prop.js +94 -0
- data/vendor/assets/components/jquery/src/attributes/support.js +35 -0
- data/vendor/assets/components/jquery/src/attributes/val.js +161 -0
- data/vendor/assets/components/jquery/src/callbacks.js +205 -0
- data/vendor/assets/components/jquery/src/core.js +502 -0
- data/vendor/assets/components/jquery/src/core/access.js +60 -0
- data/vendor/assets/components/jquery/src/core/init.js +123 -0
- data/vendor/assets/components/jquery/src/core/parseHTML.js +39 -0
- data/vendor/assets/components/jquery/src/core/ready.js +97 -0
- data/vendor/assets/components/jquery/src/core/var/rsingleTag.js +4 -0
- data/vendor/assets/components/jquery/src/css.js +450 -0
- data/vendor/assets/components/jquery/src/css/addGetHookIf.js +22 -0
- data/vendor/assets/components/jquery/src/css/curCSS.js +57 -0
- data/vendor/assets/components/jquery/src/css/defaultDisplay.js +70 -0
- data/vendor/assets/components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/vendor/assets/components/jquery/src/css/support.js +96 -0
- data/vendor/assets/components/jquery/src/css/swap.js +28 -0
- data/vendor/assets/components/jquery/src/css/var/cssExpand.js +3 -0
- data/vendor/assets/components/jquery/src/css/var/getStyles.js +12 -0
- data/vendor/assets/components/jquery/src/css/var/isHidden.js +13 -0
- data/vendor/assets/components/jquery/src/css/var/rmargin.js +3 -0
- data/vendor/assets/components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/vendor/assets/components/jquery/src/data.js +178 -0
- data/vendor/assets/components/jquery/src/data/Data.js +181 -0
- data/vendor/assets/components/jquery/src/data/accepts.js +20 -0
- data/vendor/assets/components/jquery/src/data/var/data_priv.js +5 -0
- data/vendor/assets/components/jquery/src/data/var/data_user.js +5 -0
- data/vendor/assets/components/jquery/src/deferred.js +149 -0
- data/vendor/assets/components/jquery/src/deprecated.js +13 -0
- data/vendor/assets/components/jquery/src/dimensions.js +50 -0
- data/vendor/assets/components/jquery/src/effects.js +648 -0
- data/vendor/assets/components/jquery/src/effects/Tween.js +114 -0
- data/vendor/assets/components/jquery/src/effects/animatedSelector.js +13 -0
- data/vendor/assets/components/jquery/src/event.js +868 -0
- data/vendor/assets/components/jquery/src/event/ajax.js +13 -0
- data/vendor/assets/components/jquery/src/event/alias.js +39 -0
- data/vendor/assets/components/jquery/src/event/support.js +9 -0
- data/vendor/assets/components/jquery/src/exports/amd.js +24 -0
- data/vendor/assets/components/jquery/src/exports/global.js +32 -0
- data/vendor/assets/components/jquery/src/intro.js +44 -0
- data/vendor/assets/components/jquery/src/jquery.js +37 -0
- data/vendor/assets/components/jquery/src/manipulation.js +580 -0
- data/vendor/assets/components/jquery/src/manipulation/_evalUrl.js +18 -0
- data/vendor/assets/components/jquery/src/manipulation/support.js +32 -0
- data/vendor/assets/components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/vendor/assets/components/jquery/src/offset.js +207 -0
- data/vendor/assets/components/jquery/src/outro.js +1 -0
- data/vendor/assets/components/jquery/src/queue.js +142 -0
- data/vendor/assets/components/jquery/src/queue/delay.js +22 -0
- data/vendor/assets/components/jquery/src/selector-native.js +172 -0
- data/vendor/assets/components/jquery/src/selector-sizzle.js +14 -0
- data/vendor/assets/components/jquery/src/selector.js +1 -0
- data/vendor/assets/components/jquery/src/serialize.js +111 -0
- data/vendor/assets/components/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/vendor/assets/components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/vendor/assets/components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/vendor/assets/components/jquery/src/traversing.js +199 -0
- data/vendor/assets/components/jquery/src/traversing/findFilter.js +100 -0
- data/vendor/assets/components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/vendor/assets/components/jquery/src/var/arr.js +3 -0
- data/vendor/assets/components/jquery/src/var/class2type.js +4 -0
- data/vendor/assets/components/jquery/src/var/concat.js +5 -0
- data/vendor/assets/components/jquery/src/var/hasOwn.js +5 -0
- data/vendor/assets/components/jquery/src/var/indexOf.js +5 -0
- data/vendor/assets/components/jquery/src/var/pnum.js +3 -0
- data/vendor/assets/components/jquery/src/var/push.js +5 -0
- data/vendor/assets/components/jquery/src/var/rnotwhite.js +3 -0
- data/vendor/assets/components/jquery/src/var/slice.js +5 -0
- data/vendor/assets/components/jquery/src/var/strundefined.js +3 -0
- data/vendor/assets/components/jquery/src/var/support.js +4 -0
- data/vendor/assets/components/jquery/src/var/toString.js +5 -0
- data/vendor/assets/components/jquery/src/wrap.js +79 -0
- data/vendor/assets/components/microplugin/.bower.json +38 -0
- data/vendor/assets/components/microplugin/.gitignore +2 -0
- data/vendor/assets/components/microplugin/.npmignore +3 -0
- data/vendor/assets/components/microplugin/README.md +115 -0
- data/vendor/assets/components/microplugin/bower.json +22 -0
- data/vendor/assets/components/microplugin/package.json +15 -0
- data/vendor/assets/components/microplugin/src/microplugin.js +135 -0
- data/vendor/assets/components/selectize/.bower.json +60 -0
- data/vendor/assets/components/selectize/.gitignore +5 -0
- data/vendor/assets/components/selectize/LICENSE +202 -0
- data/vendor/assets/components/selectize/README.md +105 -0
- data/vendor/assets/components/selectize/bower.json +40 -0
- data/vendor/assets/components/selectize/dist/css/selectize.bootstrap2.css +487 -0
- data/vendor/assets/components/selectize/dist/css/selectize.bootstrap3.css +401 -0
- data/vendor/assets/components/selectize/dist/css/selectize.css +317 -0
- data/vendor/assets/components/selectize/dist/css/selectize.default.css +387 -0
- data/vendor/assets/components/selectize/dist/css/selectize.legacy.css +364 -0
- data/vendor/assets/components/selectize/dist/js/selectize.js +3058 -0
- data/vendor/assets/components/selectize/dist/js/selectize.min.js +3 -0
- data/vendor/assets/components/selectize/dist/js/standalone/selectize.js +3667 -0
- data/vendor/assets/components/selectize/dist/js/standalone/selectize.min.js +3 -0
- data/vendor/assets/components/selectize/dist/less/plugins/drag_drop.less +16 -0
- data/vendor/assets/components/selectize/dist/less/plugins/dropdown_header.less +20 -0
- data/vendor/assets/components/selectize/dist/less/plugins/optgroup_columns.less +17 -0
- data/vendor/assets/components/selectize/dist/less/plugins/remove_button.less +37 -0
- data/vendor/assets/components/selectize/dist/less/selectize.bootstrap2.less +161 -0
- data/vendor/assets/components/selectize/dist/less/selectize.bootstrap3.less +150 -0
- data/vendor/assets/components/selectize/dist/less/selectize.default.less +84 -0
- data/vendor/assets/components/selectize/dist/less/selectize.legacy.less +75 -0
- data/vendor/assets/components/selectize/dist/less/selectize.less +295 -0
- data/vendor/assets/components/selectize/karma.conf.js +107 -0
- data/vendor/assets/components/sifter/.bower.json +44 -0
- data/vendor/assets/components/sifter/.gitignore +3 -0
- data/vendor/assets/components/sifter/.npmignore +4 -0
- data/vendor/assets/components/sifter/README.md +149 -0
- data/vendor/assets/components/sifter/bower.json +23 -0
- data/vendor/assets/components/sifter/package.json +48 -0
- data/vendor/assets/components/sifter/sifter.js +471 -0
- data/vendor/assets/components/sifter/sifter.min.js +2 -0
- data/vendor/assets/components/sweetalert/.bower.json +36 -0
- data/vendor/assets/components/sweetalert/.editorconfig +11 -0
- data/vendor/assets/components/sweetalert/.gitignore +5 -0
- data/vendor/assets/components/sweetalert/.jshintrc +11 -0
- data/vendor/assets/components/sweetalert/.travis.yml +6 -0
- data/vendor/assets/components/sweetalert/LICENSE +22 -0
- data/vendor/assets/components/sweetalert/README.md +157 -0
- data/vendor/assets/components/sweetalert/bower.json +25 -0
- data/vendor/assets/components/sweetalert/dev/gulpfile-wrap-template.js +18 -0
- data/vendor/assets/components/sweetalert/dev/ie9.css +23 -0
- data/vendor/assets/components/sweetalert/dev/loader-animation.css +209 -0
- data/vendor/assets/components/sweetalert/dev/modules/default-params.js +26 -0
- data/vendor/assets/components/sweetalert/dev/modules/handle-click.js +128 -0
- data/vendor/assets/components/sweetalert/dev/modules/handle-dom.js +161 -0
- data/vendor/assets/components/sweetalert/dev/modules/handle-key.js +73 -0
- data/vendor/assets/components/sweetalert/dev/modules/handle-swal-dom.js +148 -0
- data/vendor/assets/components/sweetalert/dev/modules/injected-html.js +69 -0
- data/vendor/assets/components/sweetalert/dev/modules/set-params.js +221 -0
- data/vendor/assets/components/sweetalert/dev/modules/utils.js +71 -0
- data/vendor/assets/components/sweetalert/dev/sweetalert.es6.js +311 -0
- data/vendor/assets/components/sweetalert/dev/sweetalert.scss +648 -0
- data/vendor/assets/components/sweetalert/dist/sweetalert-dev.js +1281 -0
- data/vendor/assets/components/sweetalert/dist/sweetalert.css +932 -0
- data/vendor/assets/components/sweetalert/dist/sweetalert.min.js +1 -0
- data/vendor/assets/components/sweetalert/example/example.css +442 -0
- data/vendor/assets/components/sweetalert/example/example.scss +580 -0
- data/vendor/assets/components/sweetalert/example/images/logo_big.png +0 -0
- data/vendor/assets/components/sweetalert/example/images/logo_big@2x.png +0 -0
- data/vendor/assets/components/sweetalert/example/images/logo_small.png +0 -0
- data/vendor/assets/components/sweetalert/example/images/logo_small@2x.png +0 -0
- data/vendor/assets/components/sweetalert/example/images/te-logo-small.svg +12 -0
- data/vendor/assets/components/sweetalert/example/images/thumbs-up.jpg +0 -0
- data/vendor/assets/components/sweetalert/example/images/vs_icon.png +0 -0
- data/vendor/assets/components/sweetalert/example/images/vs_icon@2x.png +0 -0
- data/vendor/assets/components/sweetalert/gulpfile.js +97 -0
- data/vendor/assets/components/sweetalert/index.html +584 -0
- data/vendor/assets/components/sweetalert/package.json +45 -0
- data/vendor/assets/components/sweetalert/sweetalert.gif +0 -0
- data/vendor/assets/components/sweetalert/test/index.html +20 -0
- data/vendor/assets/components/sweetalert/test/tests.js +143 -0
- data/vendor/assets/components/sweetalert/themes/facebook/facebook.css +111 -0
- data/vendor/assets/components/sweetalert/themes/facebook/facebook.scss +146 -0
- data/vendor/assets/components/sweetalert/themes/google/google.css +115 -0
- data/vendor/assets/components/sweetalert/themes/google/google.scss +148 -0
- data/vendor/assets/components/sweetalert/themes/twitter/twitter.css +140 -0
- data/vendor/assets/components/sweetalert/themes/twitter/twitter.scss +177 -0
- metadata +214 -5
- data/abstracted-0.0.4.gem +0 -0
- data/abstracted.gemspec +0 -51
- data/app/views/abstract_resources/index.html.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 513a8bc84b158cd7bb649f5285a1dc0fe78355ac
|
4
|
+
data.tar.gz: 0b83926221a0c3ffd888981cd91e3ad7f889ecd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577b3ae9339f08e18654b069c3fe58de050bac967b4f2fdbd6fdbc77df5215d96ed6a8609141dcaa5135554ee792f6294a9ceee983ae4c4563c1afbd72f79ef6
|
7
|
+
data.tar.gz: 236c8bd7c3592f877a011e3a382dc3ba1fc1c9477fdc4d80bbbc3cb866bd34ffb362565a0c6ffcd3b86e68c6c949fd28928527dc80ee440e6b8ec1cd9903a469
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
abstracted (0.0.
|
4
|
+
abstracted (0.0.10)
|
5
|
+
kaminari
|
5
6
|
pundit
|
6
7
|
rails (~> 4.1)
|
7
8
|
responders
|
@@ -44,10 +45,8 @@ GEM
|
|
44
45
|
minitest (~> 5.1)
|
45
46
|
thread_safe (~> 0.3, >= 0.3.4)
|
46
47
|
tzinfo (~> 1.1)
|
47
|
-
arel (6.0.
|
48
|
+
arel (6.0.3)
|
48
49
|
builder (3.2.2)
|
49
|
-
byebug (5.0.0)
|
50
|
-
columnize (= 0.9.0)
|
51
50
|
capybara (2.4.4)
|
52
51
|
mime-types (>= 1.16)
|
53
52
|
nokogiri (>= 1.3.3)
|
@@ -57,7 +56,6 @@ GEM
|
|
57
56
|
celluloid (0.16.0)
|
58
57
|
timers (~> 4.0.0)
|
59
58
|
coderay (1.1.0)
|
60
|
-
columnize (0.9.0)
|
61
59
|
combustion (0.5.3)
|
62
60
|
activesupport (>= 3.0.0)
|
63
61
|
railties (>= 3.0.0)
|
@@ -72,7 +70,7 @@ GEM
|
|
72
70
|
railties (>= 3.0.0)
|
73
71
|
ffi (1.9.6)
|
74
72
|
formatador (0.2.5)
|
75
|
-
globalid (0.3.
|
73
|
+
globalid (0.3.6)
|
76
74
|
activesupport (>= 4.1.0)
|
77
75
|
guard (2.12.4)
|
78
76
|
formatador (>= 0.2.4)
|
@@ -91,6 +89,9 @@ GEM
|
|
91
89
|
hitimes (1.2.2)
|
92
90
|
i18n (0.7.0)
|
93
91
|
json (1.8.2)
|
92
|
+
kaminari (0.16.3)
|
93
|
+
actionpack (>= 3.0.0)
|
94
|
+
activesupport (>= 3.0.0)
|
94
95
|
listen (2.8.5)
|
95
96
|
celluloid (>= 0.15.2)
|
96
97
|
rb-fsevent (>= 0.9.3)
|
@@ -182,7 +183,7 @@ GEM
|
|
182
183
|
slop (3.6.0)
|
183
184
|
sprockets (3.2.0)
|
184
185
|
rack (~> 1.0)
|
185
|
-
sprockets-rails (2.3.
|
186
|
+
sprockets-rails (2.3.2)
|
186
187
|
actionpack (>= 3.0)
|
187
188
|
activesupport (>= 3.0)
|
188
189
|
sprockets (>= 2.8, < 4.0)
|
@@ -202,7 +203,6 @@ PLATFORMS
|
|
202
203
|
|
203
204
|
DEPENDENCIES
|
204
205
|
abstracted!
|
205
|
-
byebug
|
206
206
|
capybara
|
207
207
|
combustion (~> 0.5.3)
|
208
208
|
database_cleaner
|
@@ -216,3 +216,6 @@ DEPENDENCIES
|
|
216
216
|
rspec-nc
|
217
217
|
rspec-rails
|
218
218
|
sqlite3
|
219
|
+
|
220
|
+
BUNDLED WITH
|
221
|
+
1.10.5
|
@@ -1,5 +1,9 @@
|
|
1
1
|
// Place all the behaviors and hooks related to the matching controller here.
|
2
2
|
// All this logic will automatically be available in application.js.
|
3
|
+
// require materialize-tags/dist/js/materialize-tags.min.js
|
4
|
+
//= require selectize/dist/js/standalone/selectize.js
|
5
|
+
// require typeahead
|
6
|
+
//= require sweetalert
|
3
7
|
//= require_tree .
|
4
8
|
|
5
9
|
|
@@ -12,28 +16,28 @@
|
|
12
16
|
//
|
13
17
|
// // or within a defer or a non async script
|
14
18
|
// document.addEventListener('DOMContentLoaded', disableMultipleSubmits, false);
|
15
|
-
$(document).ready(function(){
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
});
|
19
|
+
// $(document).ready(function(){
|
20
|
+
// function disableMultipleSubmits() { // by Andrea Giammarchi - WTFPL
|
21
|
+
// Array.prototype.forEach.call(
|
22
|
+
// document.querySelectorAll('form[disablemultiplesubmits]'),
|
23
|
+
// function (form) {
|
24
|
+
// form.addEventListener('submit', this, true);
|
25
|
+
// },
|
26
|
+
// {
|
27
|
+
// // button to disable
|
28
|
+
// query: 'input[type=submit],button[type=submit]',
|
29
|
+
// // delay before re-enabling
|
30
|
+
// delay: 500,
|
31
|
+
// // handler
|
32
|
+
// handleEvent: function (e) {
|
33
|
+
// var button = e.currentTarget.querySelector(this.query);
|
34
|
+
// button.disabled = true;
|
35
|
+
// setTimeout(function () {
|
36
|
+
// console.log('submit re-enabled');
|
37
|
+
// button.disabled = false;
|
38
|
+
// }, this.delay);
|
39
|
+
// }
|
40
|
+
// }
|
41
|
+
// );
|
42
|
+
// }
|
43
|
+
// });
|
@@ -1,3 +1,12 @@
|
|
1
|
+
#
|
2
|
+
# searchPost handles ordering search on index actions
|
3
|
+
#
|
4
|
+
@orderSearch = (url,query) ->
|
5
|
+
loader = '<div class="preloader-wrapper small active"> <div class="spinner-layer spinner-blue-only"> <div class="circle-clipper left"> <div class="circle"></div> </div><div class="gap-patch"> <div class="circle"></div> </div><div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div>'
|
6
|
+
loaded_element = $('.fixed-action-btn')
|
7
|
+
setLoader( loaded_element,loader )
|
8
|
+
window.location.href= url + '?q=' + encodeURIComponent(query)
|
9
|
+
|
1
10
|
#
|
2
11
|
# deletePost handles deleting records
|
3
12
|
#
|
@@ -5,14 +14,6 @@
|
|
5
14
|
# sweetalert
|
6
15
|
#
|
7
16
|
# data-url="", data-id="" - eg.
|
8
|
-
|
9
|
-
closeSweetAlert = () ->
|
10
|
-
try
|
11
|
-
swal.close()
|
12
|
-
catch error
|
13
|
-
$('.sweet-overlay').hide()
|
14
|
-
$('.sweet-alert').hide()
|
15
|
-
|
16
17
|
@deletePost = ($elem) ->
|
17
18
|
try
|
18
19
|
url = $elem.data('url') + "/" + $elem.data('id') + ".js"
|
@@ -20,30 +21,174 @@ closeSweetAlert = () ->
|
|
20
21
|
request = $.ajax
|
21
22
|
url: url,
|
22
23
|
type: "delete",
|
23
|
-
|
24
|
+
dataType: 'html'
|
25
|
+
.done (data) ->
|
26
|
+
if $remove
|
27
|
+
$remove.hide()
|
28
|
+
closeSweetAlert($elem)
|
29
|
+
#swal("Deleted!", "Your file was successfully deleted!", "success")
|
30
|
+
.error (data) ->
|
31
|
+
$elem.show()
|
32
|
+
swal("Oops", "We couldn't connect to the server!", "error")
|
33
|
+
#
|
34
|
+
# statusCode:
|
35
|
+
#
|
36
|
+
# 200: (response,textStatus,jqXHR) ->
|
37
|
+
# closeSweetAlert()
|
38
|
+
# tellResponse response.responseText
|
39
|
+
#
|
40
|
+
#
|
41
|
+
# 301: () ->
|
42
|
+
# $elem.show()
|
43
|
+
# closeSweetAlert()
|
44
|
+
# swal "Ikke slettet!", "Posten blev ikke slettet - årsagen ikke kendt", "warning"
|
45
|
+
#
|
46
|
+
# 401: (response) ->
|
47
|
+
# tellResponse response.responseText
|
48
|
+
# closeSweetAlert()
|
49
|
+
#
|
50
|
+
# 409: (response) ->
|
51
|
+
# tellResponse response.responseText
|
52
|
+
# closeSweetAlert()
|
53
|
+
#
|
54
|
+
# 412: () ->
|
55
|
+
# closeSweetAlert()
|
56
|
+
# swal "Øv!", "Et eller andet gik galt!", "error"
|
24
57
|
|
25
|
-
|
26
|
-
|
27
|
-
$remove.hide()
|
28
|
-
closeSweetAlert()
|
29
|
-
$('.message_container').html(response.responseText)
|
58
|
+
catch error
|
59
|
+
swal "Hmmm", "Most unexpected! \n#{error}", "error"
|
30
60
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
61
|
+
#
|
62
|
+
# printPost handles printing posts either way
|
63
|
+
#
|
64
|
+
# dependencies
|
65
|
+
#
|
66
|
+
#
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# <a
|
70
|
+
# class="print_post_link"
|
71
|
+
# data-ajax="get"
|
72
|
+
# data-remote="false"
|
73
|
+
# data-method="get"
|
74
|
+
# data-download="true" -- if is is a file which we should send!
|
75
|
+
# data-url="/stock_items/1/print.js"
|
76
|
+
# data-oxremote="true"
|
77
|
+
# data-name="2"
|
78
|
+
# data-id="1"
|
79
|
+
# data-paper="label"
|
80
|
+
# data-message-ok="Udskrivning af Labels bestilt!"
|
81
|
+
# data-message-error="øv"
|
82
|
+
# href="http://localhost:3000/stock_items/1/print">
|
83
|
+
# <i class="mdi-action-label small" title="Udskriv labels"></i>
|
84
|
+
# </a>
|
85
|
+
#
|
86
|
+
# data-url="", data-id="", data-print-action="", data-message-ok="", data-message-error=""
|
87
|
+
@printPost = (elem) ->
|
88
|
+
elem = $(elem)
|
89
|
+
url = elem.data('url') || elem.attr('href')
|
90
|
+
if elem.data('browser')=='new'
|
91
|
+
releaseLoader()
|
92
|
+
window.open url + '?' + $.param dataArgumentOn(elem)
|
93
|
+
return
|
35
94
|
|
36
|
-
|
37
|
-
|
38
|
-
|
95
|
+
oxremote = elem.data('oxremote')
|
96
|
+
if oxremote=='false'
|
97
|
+
switch elem.data('method')
|
98
|
+
when 'post', 'POST'
|
99
|
+
# elem.closest('form').submit()
|
100
|
+
$('form').submit()
|
101
|
+
when 'put', 'PUT'
|
102
|
+
console.log 'how do I put? add code in abstracted/app/assets/javascripts/initializers.js.coffee'
|
103
|
+
when 'get', 'GET'
|
104
|
+
window.location.href = elem.data('url')
|
105
|
+
else
|
106
|
+
try
|
107
|
+
jqxhr = $.ajax
|
108
|
+
url: elem.data('url') || elem.attr('href')
|
109
|
+
type: elem.data('method') || 'get'
|
110
|
+
data: dataArgumentOn(elem)
|
111
|
+
dataType: elem.data('type') || 'html'
|
112
|
+
.done (data) ->
|
113
|
+
releaseLoader()
|
114
|
+
if elem.data('download')
|
115
|
+
getDownload(jqxhr,data)
|
116
|
+
else
|
117
|
+
$(document.body).append(data)
|
39
118
|
|
40
|
-
|
41
|
-
|
42
|
-
|
119
|
+
.fail (response,status) ->
|
120
|
+
releaseLoader()
|
121
|
+
if jqxhr.state=='rejected'
|
122
|
+
reportError('Der er ingen forbindelse til serveren - prøv lidt senere!')
|
123
|
+
else
|
124
|
+
$(document.body).append(response.responseText)
|
43
125
|
|
44
|
-
|
45
|
-
|
46
|
-
swal "Øv!", "Et eller andet gik galt!", "error"
|
126
|
+
catch e
|
127
|
+
console.log e
|
47
128
|
|
48
|
-
|
49
|
-
|
129
|
+
return false
|
130
|
+
|
131
|
+
@getDownload = (xhr,data) ->
|
132
|
+
# Check if a filename is existing on the response headers.
|
133
|
+
filename = ""
|
134
|
+
disposition = xhr.getResponseHeader("Content-Disposition")
|
135
|
+
if disposition && disposition.indexOf("attachment") != -1
|
136
|
+
filenameRegex = /filename[^;=\n]*=(([""]).*?\2|[^;\n]*)/
|
137
|
+
matches = filenameRegex.exec(disposition)
|
138
|
+
if matches != null && matches[1]
|
139
|
+
filename = matches[1].replace(/[""]/g, "")
|
140
|
+
#
|
141
|
+
type = xhr.getResponseHeader("Content-Type")
|
142
|
+
console.log 'getDownload ' + type
|
143
|
+
blob = new Blob([data], {type: type})
|
144
|
+
#
|
145
|
+
if typeof window.navigator.msSaveBlob != "undefined"
|
146
|
+
# // IE workaround for "HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed.
|
147
|
+
window.navigator.msSaveBlob(blob, filename)
|
148
|
+
else
|
149
|
+
URL = window.URL || window.webkitURL
|
150
|
+
downloadUrl = URL.createObjectURL(blob)
|
151
|
+
downloadUrl.oneTimeOnly = true
|
152
|
+
#
|
153
|
+
if filename
|
154
|
+
# // Use HTML5 a[download] attribute to specify filename.
|
155
|
+
a = document.createElement("a")
|
156
|
+
# // Safari doesn"t support this yet.
|
157
|
+
if typeof a.download == "undefined"
|
158
|
+
window.location = downloadUrl
|
159
|
+
else
|
160
|
+
a.href = downloadUrl
|
161
|
+
a.download = filename
|
162
|
+
document.body.appendChild(a)
|
163
|
+
a.click()
|
164
|
+
else
|
165
|
+
window.location = downloadUrl
|
166
|
+
|
167
|
+
#
|
168
|
+
# setTimeout () ->
|
169
|
+
# URL.revokeObjectURL(downloadUrl)
|
170
|
+
# , 100
|
171
|
+
#
|
172
|
+
#
|
173
|
+
#
|
174
|
+
# blob=new Blob([data])
|
175
|
+
# link=document.createElement('a')
|
176
|
+
# link.href=window.URL.createObjectURL(blob)
|
177
|
+
# # link.target='_blank';
|
178
|
+
# link.download="oxen_"+new Date()+".pdf"
|
179
|
+
# link.click()
|
180
|
+
|
181
|
+
# @printPost = ($elem) ->
|
182
|
+
# try
|
183
|
+
# url = $elem.data('url') + "/" + $elem.data('id') + '/' + $elem.data('print-action') + ".js"
|
184
|
+
# request = $.ajax
|
185
|
+
# url: url,
|
186
|
+
# type: "post",
|
187
|
+
# data: $elem.data('data'),
|
188
|
+
# dataType: 'html'
|
189
|
+
# .done (data) ->
|
190
|
+
# releaseLoader($elem.closest('.loader_container'))
|
191
|
+
# $(document.body).append(data)
|
192
|
+
# .error (data) ->
|
193
|
+
# releaseLoader($elem.closest('.loader_container'))
|
194
|
+
# $(document.body).append(data)
|
@@ -1,48 +1,301 @@
|
|
1
|
+
# this var holds whatever HTML has been parked
|
2
|
+
# to make room for a loader
|
3
|
+
#
|
4
|
+
|
5
|
+
# cloneObject will make a copy of an object - not a copy of the reference
|
6
|
+
# to some object!
|
7
|
+
#
|
8
|
+
# var obj1= {bla:'blabla',foo:'foofoo',etc:'etc'};
|
9
|
+
# var obj2= new cloneObject(obj1);
|
10
|
+
#
|
11
|
+
# 03-07-2015 (whd) not sure whether this method is OK!!!!
|
12
|
+
# cp'ed from: http://scriptcult.com/subcategory_1/article_414-copy-or-clone-javascript-array-object
|
13
|
+
#
|
14
|
+
@cloneObject = (source) ->
|
15
|
+
for i in source
|
16
|
+
if typeof source[i] == 'source'
|
17
|
+
this[i] = new cloneObject source[i]
|
18
|
+
else
|
19
|
+
this[i] = source[i]
|
20
|
+
|
21
|
+
|
22
|
+
# it will be re-instated with releaseLoader
|
23
|
+
loaded_html = ""
|
24
|
+
loaded_element = ""
|
25
|
+
|
26
|
+
#
|
27
|
+
# set a loader - see http://materializecss.com/preloader.html
|
28
|
+
# for examples
|
29
|
+
#
|
30
|
+
@setLoader = (elem,html) ->
|
31
|
+
html ||= '<div class="progress"><div class="indeterminate"></div></div>'
|
32
|
+
loaded_element = $(elem)
|
33
|
+
loaded_html = elem.html()
|
34
|
+
elem.html(html)
|
35
|
+
|
36
|
+
#
|
37
|
+
# release the loader
|
38
|
+
#
|
39
|
+
@releaseLoader = (elem=null) ->
|
40
|
+
elem ||= loaded_element
|
41
|
+
$(elem).html(loaded_html)
|
42
|
+
|
43
|
+
#
|
44
|
+
# make sure fields with values do not have their labels obscuring your view
|
45
|
+
#
|
46
|
+
@setLabels = (selector) ->
|
47
|
+
$(selector).each () ->
|
48
|
+
try
|
49
|
+
fld = '#'+$(this).attr('for')
|
50
|
+
$(this).addClass('active') unless $(fld)[0].value.nil?
|
51
|
+
catch
|
52
|
+
#console.log this
|
53
|
+
|
54
|
+
|
55
|
+
@tellResponse = (msg,anchor='.message_container',fade=15000,selector='.alert') ->
|
56
|
+
$(anchor).prepend(msg)
|
57
|
+
if fade>0
|
58
|
+
fadeItOut $(anchor).find(selector), 15000
|
59
|
+
|
60
|
+
@reportError = (msg) ->
|
61
|
+
Materialize.toast( msg, 4500, 'red lighten-3')
|
62
|
+
|
63
|
+
@closeSweetAlert = ($elem=null) ->
|
64
|
+
try
|
65
|
+
unless $elem == undefined
|
66
|
+
$elem.show()
|
67
|
+
swal.close()
|
68
|
+
catch error
|
69
|
+
$('.sweet-overlay').hide()
|
70
|
+
$('.sweet-alert').hide()
|
71
|
+
|
72
|
+
|
1
73
|
#
|
2
74
|
# initializeSweetAlert
|
3
75
|
# initializes the sweetalert prompt
|
4
76
|
#
|
5
77
|
@initializeSweetAlert = () ->
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
78
|
+
try
|
79
|
+
# console.log 'sweet alert initializing...'
|
80
|
+
# sweetHTML = '<div class="sweet-overlay" tabIndex="-1"></div><div class="sweet-alert" tabIndex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <div class="icon custom"></div> <h2>Title</h2><p>Text</p><button class="cancel" tabIndex="2">Cancel</button><button class="confirm" tabIndex="1">OK</button></div>'
|
81
|
+
# sweetWrap = document.createElement('div')
|
82
|
+
# sweetWrap.innerHTML = sweetHTML
|
83
|
+
# $(document.body).append(sweetWrap)
|
84
|
+
# console.log 'sweetalert initialized!'
|
85
|
+
catch error
|
86
|
+
console.log 'sweetalert says: ' + error
|
87
|
+
|
88
|
+
#
|
89
|
+
# handleAttachLinks
|
90
|
+
# allows for attaching/detaching resources from their parents - like: /admin/users/2/printers/3/attach.js
|
91
|
+
#
|
92
|
+
@handleAttachLinks = (e) ->
|
93
|
+
e.preventDefault()
|
94
|
+
e.stopPropagation()
|
95
|
+
|
96
|
+
$elem = $(e.currentTarget)
|
97
|
+
request = $.ajax
|
98
|
+
url: $elem.attr('href'),
|
99
|
+
type: "get",
|
100
|
+
dataType: 'html'
|
101
|
+
.done (data) ->
|
102
|
+
$( $elem[0].parentElement).html(data)
|
103
|
+
|
104
|
+
.error (data) ->
|
105
|
+
swal("Oops", "We couldn't connect to the server!", "error")
|
106
|
+
return false
|
107
|
+
|
108
|
+
#
|
109
|
+
# handleActivateLinks
|
110
|
+
# allows for activating/deactivating resources - like: /admin/users/2/activate
|
111
|
+
#
|
112
|
+
@handleActivateLinks = (e) ->
|
113
|
+
e.preventDefault()
|
114
|
+
e.stopPropagation()
|
14
115
|
|
116
|
+
$elem = $(e.currentTarget)
|
117
|
+
request = $.ajax
|
118
|
+
url: $elem.attr('href'),
|
119
|
+
type: "get",
|
120
|
+
dataType: 'html'
|
121
|
+
.done (data) ->
|
122
|
+
$( $elem[0].parentElement).html(data)
|
15
123
|
|
124
|
+
.error (data) ->
|
125
|
+
swal("Oops", "We couldn't connect to the server!", "error")
|
126
|
+
return false
|
127
|
+
|
128
|
+
|
129
|
+
#
|
130
|
+
# handlePreferredLinks
|
131
|
+
# allows for activating/deactivating resources - like: /admin/users/2/activate
|
132
|
+
#
|
133
|
+
@handlePreferredLinks = (e) ->
|
134
|
+
e.preventDefault()
|
135
|
+
e.stopPropagation()
|
136
|
+
|
137
|
+
$elem = $(e.currentTarget)
|
138
|
+
request = $.ajax
|
139
|
+
url: $elem.attr('href'),
|
140
|
+
type: "get",
|
141
|
+
dataType: 'html'
|
142
|
+
.done (data) ->
|
143
|
+
# here we have to write all the existing preferred ones
|
144
|
+
$.when $('i.preferred').each (k,e) ->
|
145
|
+
$e = $(e)
|
146
|
+
$( $e[0].parentElement).html( data.replace /{{id}}/, $e.data('id'))
|
147
|
+
# $( $elem[0].parentElement).html(data)
|
148
|
+
.then $( $elem[0].parentElement).html('<i class="preferred material-icons green-text" data-id="' + $elem.data('id') + '">bookmark</i>')
|
149
|
+
|
150
|
+
.error (data) ->
|
151
|
+
swal("Oops", "We couldn't connect to the server!", "error")
|
152
|
+
return false
|
153
|
+
|
154
|
+
#
|
155
|
+
# handlePrintLinks
|
156
|
+
# initializes the tags classed with '.print_post_link' to print a post
|
16
157
|
#
|
17
|
-
|
158
|
+
@handlePrintLinks = (e) ->
|
159
|
+
e.preventDefault()
|
160
|
+
e.stopPropagation()
|
161
|
+
|
162
|
+
$elem = $(e.currentTarget)
|
163
|
+
loader = '<div class="preloader-wrapper small active"> <div class="spinner-layer spinner-blue-only"> <div class="circle-clipper left"> <div class="circle"></div> </div><div class="gap-patch"> <div class="circle"></div> </div><div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div>'
|
164
|
+
loaded_element = $elem.closest('.loader_container')
|
165
|
+
setLoader( loaded_element,loader )
|
166
|
+
printPost($elem)
|
167
|
+
return false
|
168
|
+
|
169
|
+
#
|
170
|
+
# handleDeleteLinks
|
18
171
|
# initializes the tags classed with '.delete_link' to verify deleting an issue
|
19
172
|
#
|
20
|
-
@
|
21
|
-
|
173
|
+
@handleDeleteLinks = (e) ->
|
174
|
+
e.preventDefault()
|
175
|
+
e.stopPropagation()
|
176
|
+
$elem = $(e.currentTarget)
|
177
|
+
$elem.hide()
|
178
|
+
|
179
|
+
$('.sweet-overlay').show()
|
180
|
+
swal
|
181
|
+
title: "Are you sure?",
|
182
|
+
text: "Are you sure that you want to delete this photo?",
|
183
|
+
type: "warning",
|
184
|
+
animation: "slide-from-bottom",
|
185
|
+
showLoaderOnConfirm: true,
|
186
|
+
showCancelButton: true,
|
187
|
+
closeOnConfirm: false,
|
188
|
+
confirmButtonText: "Yes, delete it!",
|
189
|
+
confirmButtonColor: "#ec6c62",
|
190
|
+
(confirmed) ->
|
191
|
+
if !confirmed
|
192
|
+
closeSweetAlert($elem)
|
193
|
+
else
|
194
|
+
deletePost($elem)
|
195
|
+
return false
|
196
|
+
|
197
|
+
#
|
198
|
+
# starting a search - and making some noise about it!
|
199
|
+
#
|
200
|
+
@searchKey = (e) ->
|
201
|
+
if e.keyCode == 13
|
22
202
|
e.preventDefault()
|
23
|
-
|
24
|
-
$elem.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
203
|
+
e.stopPropagation()
|
204
|
+
$elem = $('input.search-list')
|
205
|
+
orderSearch(inputForm.action, $elem.val())
|
206
|
+
|
207
|
+
#
|
208
|
+
# starting a search - and making some noise about it!
|
209
|
+
#
|
210
|
+
@searchClick = (e) ->
|
211
|
+
e.preventDefault()
|
212
|
+
e.stopPropagation()
|
213
|
+
$elem = $('input.search-list')
|
214
|
+
orderSearch(inputForm.action, $elem.val())
|
215
|
+
|
216
|
+
|
217
|
+
inputForm = null
|
218
|
+
#
|
219
|
+
# initializeForm
|
220
|
+
# on pages with a FORM element - like show, new and edit
|
221
|
+
# prepare the FORM element
|
222
|
+
#
|
223
|
+
@initializeForm = (f) ->
|
224
|
+
inputForm = f
|
225
|
+
#
|
226
|
+
# Initialize SELECT's
|
227
|
+
#
|
228
|
+
$('select').each () ->
|
229
|
+
# remove span.caret's from previous 'runs' - however that happens
|
230
|
+
$(this).parent().parent().find('span.caret').remove()
|
231
|
+
$(this).material_select()
|
232
|
+
|
233
|
+
#
|
234
|
+
# make labels on fields with content move out of the way
|
235
|
+
#
|
236
|
+
setLabels('.input-field label')
|
237
|
+
|
238
|
+
$(document.body).on 'keydown.search', 'input.search-list', searchKey
|
239
|
+
$(document.body).on 'click.search', 'form a.search-list[type="submit"]', searchClick
|
240
|
+
|
241
|
+
#
|
242
|
+
# Initialize INPUT TYPE='DATE'
|
243
|
+
#
|
244
|
+
# %input.datepicker{ type:"date" }
|
245
|
+
#
|
246
|
+
$('.datepicker').pickadate
|
247
|
+
selectMonths: true, # Creates a dropdown to control month
|
248
|
+
selectYears: 15 # Creates a dropdown of 15 years to control year
|
249
|
+
|
250
|
+
#
|
251
|
+
# setup a dropbox file upload
|
252
|
+
#
|
253
|
+
@prepareUpload = (e) ->
|
254
|
+
if $('.dropbox').size() > 0
|
255
|
+
medium = new Medium()
|
256
|
+
medium.initializeBindings()
|
257
|
+
|
258
|
+
|
259
|
+
#
|
260
|
+
# handleFABLinks
|
261
|
+
# handles click on the fab_button
|
262
|
+
#
|
263
|
+
@handleFABLinks = (e) ->
|
264
|
+
e.preventDefault()
|
265
|
+
e.stopPropagation()
|
266
|
+
elem = $(e.currentTarget)
|
267
|
+
if elem.data('browser')=='new'
|
268
|
+
window.open elem.data('url')
|
269
|
+
return
|
45
270
|
|
271
|
+
loader = '<div class="preloader-wrapper medium active"> <div class="spinner-layer spinner-blue-only"> <div class="circle-clipper left"> <div class="circle"></div> </div><div class="gap-patch"> <div class="circle"></div> </div><div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div>'
|
272
|
+
setLoader( $(elem).closest('.fixed-action-btn'),loader)
|
273
|
+
oxremote = elem.data('oxremote')
|
274
|
+
if (oxremote=='false' or oxremote==false)
|
275
|
+
switch elem.data('method')
|
276
|
+
when 'post', 'POST'
|
277
|
+
# elem.closest('form').submit()
|
278
|
+
$('form').submit()
|
279
|
+
when 'put', 'PUT'
|
280
|
+
console.log 'how do I put? add code in abstracted/app/assets/javascripts/initializers.js.coffee'
|
281
|
+
when 'get', 'GET'
|
282
|
+
window.location.href = elem.data('url')
|
283
|
+
else
|
284
|
+
jqxhr = $.ajax
|
285
|
+
url: elem.data('url') || elem.attr('href')
|
286
|
+
type: elem.data('method') || 'get'
|
287
|
+
data: dataArgumentOn(elem)
|
288
|
+
dataType: elem.data('type') || 'html'
|
289
|
+
.done (data) ->
|
290
|
+
releaseLoader()
|
291
|
+
if elem.data('modal')
|
292
|
+
$(elem.data('modal')).html(data).openModal()
|
293
|
+
else
|
294
|
+
$(document.body).append(data)
|
295
|
+
.error (data) ->
|
296
|
+
releaseLoader()
|
297
|
+
$(document.body).append(data)
|
298
|
+
return false
|
46
299
|
|
47
300
|
#
|
48
301
|
# fadeItOut will fade an element out with a preset or
|
@@ -51,6 +304,20 @@
|
|
51
304
|
@fadeItOut = (e,delay=3500) ->
|
52
305
|
$(e).delay( delay ).fadeOut( 1000 )
|
53
306
|
|
307
|
+
#
|
308
|
+
# dataArgumentOn constructs the data: argument on AJAX calls
|
309
|
+
# from what ever data- attributes an element holds
|
310
|
+
#
|
311
|
+
# excemptions: data-id, data-remote, data-ajax, data-method, data-type and data-url
|
312
|
+
#
|
313
|
+
@dataArgumentOn = (elem) ->
|
314
|
+
$(elem).data()
|
315
|
+
|
316
|
+
#
|
317
|
+
# closeNotice
|
318
|
+
# will close the notice DIV
|
319
|
+
@closeNotice = (e) ->
|
320
|
+
fadeItOut $(e).closest('.alert') #.remove()
|
54
321
|
|
55
322
|
#
|
56
323
|
# PageOnLoad loads and initializes
|
@@ -58,11 +325,57 @@
|
|
58
325
|
#
|
59
326
|
@pageOnLoad = () ->
|
60
327
|
|
328
|
+
# fileApiSupportCheck()
|
329
|
+
#
|
330
|
+
# make sure all eventhandlers are gone!
|
331
|
+
$(document.body).unbind('click.close_notice')
|
332
|
+
$(document.body).unbind('click.print')
|
333
|
+
$(document.body).unbind('click.delete')
|
334
|
+
$(document.body).unbind('click.fab')
|
335
|
+
$(document.body).unbind('click.attach')
|
336
|
+
$(document.body).unbind('click.activate')
|
337
|
+
$(document.body).unbind('click.prefer')
|
338
|
+
$(document.body).unbind('keydown.search')
|
339
|
+
$(document.body).unbind('click.search')
|
340
|
+
|
61
341
|
#
|
62
342
|
# Initialize the 'hamburger'
|
63
343
|
#
|
64
344
|
$(".button-collapse").sideNav();
|
65
345
|
|
346
|
+
#
|
347
|
+
# Prepare close-notice's for acting on clicks to remove div
|
348
|
+
#
|
349
|
+
$(document.body).on 'click.close_notice', 'a.close-notice', closeNotice
|
350
|
+
|
351
|
+
#
|
352
|
+
# Prepare print_link's
|
353
|
+
#
|
354
|
+
$(document.body).on 'click.print', 'a.print_post_link, a.print_item', handlePrintLinks
|
355
|
+
|
356
|
+
#
|
357
|
+
# Prepare delete_link's for acting on clicks to delete posts
|
358
|
+
#
|
359
|
+
$(document.body).on 'click.delete', 'a.delete_link, a.delete_item', handleDeleteLinks
|
360
|
+
|
361
|
+
#
|
362
|
+
# Add event on the FAB (fixed action button)
|
363
|
+
#
|
364
|
+
$(document.body).on 'click.fab', 'a.fab-button', handleFABLinks
|
365
|
+
|
366
|
+
#
|
367
|
+
# else
|
368
|
+
# $form = $(e.currentTarget).closest('form')
|
369
|
+
# data = $form.serialize()
|
370
|
+
# jqxhr = $.ajax
|
371
|
+
# url: $(e.currentTarget).data('url'),
|
372
|
+
# type: $(e.currentTarget).data('method'),
|
373
|
+
# data: data
|
374
|
+
# .done (response) ->
|
375
|
+
# $('body').html(response)
|
376
|
+
# .fail (response) ->
|
377
|
+
# console.log 'øv!'
|
378
|
+
|
66
379
|
#
|
67
380
|
# Initialize collapsible (uncomment the line below if you use the dropdown variation)
|
68
381
|
#
|
@@ -70,42 +383,74 @@
|
|
70
383
|
accordion : true # A setting that changes the collapsible behavior to expandable instead of the default accordion style
|
71
384
|
|
72
385
|
#
|
73
|
-
#
|
386
|
+
# If this page has FORM element(s)
|
74
387
|
#
|
75
|
-
$('
|
388
|
+
$('form').first().map (k,f) ->
|
389
|
+
initializeForm(f)
|
390
|
+
prepareUpload(f)
|
76
391
|
|
77
392
|
#
|
78
|
-
#
|
393
|
+
# If this page has a resources_list
|
79
394
|
#
|
80
|
-
|
395
|
+
$('table.resources_table').map (k,t) ->
|
396
|
+
console.log 'table ' + k
|
397
|
+
$(document.body).on 'click.attach', 'a.attached, a.detached', handleAttachLinks
|
398
|
+
$(document.body).on 'click.activate', 'a.activated, a.deactivated', handleActivateLinks
|
399
|
+
$(document.body).on 'click.prefer', 'a.preferred, a.deferred', handlePreferredLinks
|
400
|
+
scrollTable(t)
|
401
|
+
|
81
402
|
#
|
82
|
-
|
83
|
-
|
84
|
-
|
403
|
+
# Try to keep users from double-clicking submit's
|
404
|
+
#
|
405
|
+
# document.addEventListener('DOMContentLoaded', disableMultipleSubmits, false);
|
85
406
|
|
86
407
|
#
|
87
|
-
#
|
408
|
+
# make drop-downs react nicely
|
409
|
+
#
|
410
|
+
$(".dropdown-button").dropdown()
|
411
|
+
|
412
|
+
#
|
413
|
+
# prepare for tabbed display of tabbed UL's
|
88
414
|
#
|
89
|
-
|
415
|
+
$('ul.tabs').tabs()
|
416
|
+
$('.materialboxed').materialbox()
|
90
417
|
|
91
|
-
|
92
|
-
# Try to keep users from double-clicking submit's
|
93
|
-
#
|
94
|
-
# document.addEventListener('DOMContentLoaded', disableMultipleSubmits, false);
|
418
|
+
try
|
95
419
|
|
420
|
+
if ($('.sweet-alert').length<1)
|
421
|
+
initializeSweetAlert()
|
422
|
+
if ($('.sweet-alert').length>0)
|
423
|
+
console.log 'sweet-alert initialized correctly!' #swal( 'pageOnLoad', 'pageOnLoad blev kaldt!', 'success')
|
424
|
+
|
425
|
+
catch error
|
426
|
+
console.log 'autch!'
|
427
|
+
console.log error
|
428
|
+
|
429
|
+
# try
|
96
430
|
#
|
97
|
-
#
|
431
|
+
# swal( 'pageOnLoad', 'pageOnLoad blev kaldt!', 'success')
|
98
432
|
#
|
99
|
-
|
100
|
-
|
433
|
+
# catch error
|
434
|
+
# console.log 'ok - giving up'
|
435
|
+
# console.log 'page loaded!'
|
436
|
+
|
437
|
+
#
|
438
|
+
# check to see iff this browser supperts the File APIs
|
439
|
+
#
|
440
|
+
@fileApiSupportCheck = () ->
|
441
|
+
if (window.File && window.FileReader && window.FileList && window.Blob)
|
442
|
+
# All the File APIs are supported.
|
443
|
+
console.log 'file APIs supported '
|
444
|
+
else
|
445
|
+
document.getElementById('message_container').innerHTML = '<div class="alert fade in alert-warning"><a href="#!" class="warning close-notice btn-floating btn-small waves-effect waves-light" aria-hidden="true" type="button" data-dismiss="alert"><i class="mdi-navigation-close"></i></a>This browser does not support this application fully! Use latest Chrome - or advance cautiously!</div>';
|
446
|
+
|
447
|
+
|
101
448
|
|
102
|
-
#
|
103
|
-
# make drop-downs react nicely
|
104
|
-
#
|
105
|
-
$(".dropdown-button").dropdown()
|
106
449
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
450
|
+
#
|
451
|
+
# PageOnChange really just calls a pageload - as of now 19-06-15
|
452
|
+
# fixed elements like SELECT's, Materialized's elements, et al.
|
453
|
+
#
|
454
|
+
# @pageOnChange = () ->
|
455
|
+
# console.log 'page changed '
|
456
|
+
# pageOnLoad()
|