drg_cms 0.4.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/images/drg_cms/add.png +0 -0
- data/app/assets/images/drg_cms/arrow_in.png +0 -0
- data/app/assets/images/drg_cms/arrow_out.png +0 -0
- data/app/assets/images/drg_cms/checkbox-checked.png +0 -0
- data/app/assets/images/drg_cms/checkbox-unchecked.png +0 -0
- data/app/assets/images/drg_cms/cols.png +0 -0
- data/app/assets/images/drg_cms/copy.png +0 -0
- data/app/assets/images/drg_cms/edit.png +0 -0
- data/app/assets/images/drg_cms/edit_design.png +0 -0
- data/app/assets/images/drg_cms/edit_page.png +0 -0
- data/app/assets/images/drg_cms/edit_site.png +0 -0
- data/app/assets/images/drg_cms/html.png +0 -0
- data/app/assets/images/drg_cms/pin.png +0 -0
- data/app/assets/images/drg_cms/printer.png +0 -0
- data/app/assets/images/drg_cms/reload.png +0 -0
- data/app/assets/images/drg_cms/search_16.png +0 -0
- data/app/assets/images/drg_cms/spinner.gif +0 -0
- data/app/assets/images/drg_cms/view_tile.png +0 -0
- data/app/assets/images/drg_cms/x.png +0 -0
- data/app/assets/javascripts/drg_cms/drg_cms.js +449 -0
- data/app/assets/javascripts/drg_cms/jquery-migrate.js +511 -0
- data/app/assets/javascripts/drg_cms/jquery.datetimepicker.js +1353 -0
- data/app/assets/javascripts/drg_cms/some_scripts.js +33 -0
- data/app/assets/javascripts/drg_cms_application.js +11 -0
- data/app/assets/javascripts/drg_cms_cms.js +28 -0
- data/app/assets/stylesheets/drg_cms/drg_cms.css +632 -0
- data/app/assets/stylesheets/drg_cms/jquery-ui.css +339 -0
- data/app/assets/stylesheets/drg_cms/jquery.datetimepicker.css +304 -0
- data/app/assets/stylesheets/drg_cms/th-bg.png +0 -0
- data/app/assets/stylesheets/drg_cms/theme.css +49 -0
- data/app/assets/stylesheets/drg_cms_application.css +12 -0
- data/app/assets/stylesheets/drg_cms_cms.css +26 -0
- data/app/controllers/cmsedit_controller.rb +673 -0
- data/app/controllers/dc_application_controller.rb +385 -0
- data/app/controllers/dc_at_the_beginning_controller.rb +120 -0
- data/app/controllers/dc_common_controller.rb +314 -0
- data/app/controllers/dc_mail_controller.rb +89 -0
- data/app/controllers/dc_main_controller.rb +40 -0
- data/app/controllers/drgcms_controls/dc_page_controls.rb +40 -0
- data/app/forms/all_options.yml +176 -0
- data/app/forms/cms_forms.yml +93 -0
- data/app/forms/cms_menu.yml +142 -0
- data/app/forms/dc_ad.yml +130 -0
- data/app/forms/dc_big_table.yml +59 -0
- data/app/forms/dc_big_table_locale.yml +41 -0
- data/app/forms/dc_big_table_value.yml +47 -0
- data/app/forms/dc_category.yml +57 -0
- data/app/forms/dc_design.yml +68 -0
- data/app/forms/dc_folder_permission.yml +49 -0
- data/app/forms/dc_forum_cat.yml +54 -0
- data/app/forms/dc_forum_forum.yml +53 -0
- data/app/forms/dc_forum_msg.yml +124 -0
- data/app/forms/dc_forum_privmsg.yml +125 -0
- data/app/forms/dc_forum_topic.yml +131 -0
- data/app/forms/dc_journal.yml +85 -0
- data/app/forms/dc_link.yml +55 -0
- data/app/forms/dc_mail.yml +88 -0
- data/app/forms/dc_mail_address.yml +56 -0
- data/app/forms/dc_mail_list.yml +44 -0
- data/app/forms/dc_mail_list_member.yml +42 -0
- data/app/forms/dc_menu.yml +62 -0
- data/app/forms/dc_menu_item.yml +81 -0
- data/app/forms/dc_page.yml +145 -0
- data/app/forms/dc_part.yml +102 -0
- data/app/forms/dc_permission.yml +50 -0
- data/app/forms/dc_piece.yml +105 -0
- data/app/forms/dc_policy.yml +57 -0
- data/app/forms/dc_policy_role.yml +42 -0
- data/app/forms/dc_policy_rule.yml +38 -0
- data/app/forms/dc_policy_rule_nocms.yml +38 -0
- data/app/forms/dc_poll.yml +113 -0
- data/app/forms/dc_poll_item.yml +76 -0
- data/app/forms/dc_simple_menu.yml +64 -0
- data/app/forms/dc_simple_menu_item.yml +80 -0
- data/app/forms/dc_site.yml +149 -0
- data/app/forms/dc_user.yml +142 -0
- data/app/forms/dc_user_role.yml +54 -0
- data/app/forms/drgcms_cms.yml +28 -0
- data/app/helpers/cmsedit_helper.rb +698 -0
- data/app/helpers/dc_ad_renderer.rb +206 -0
- data/app/helpers/dc_application_helper.rb +704 -0
- data/app/helpers/dc_big_menu_renderer.rb +180 -0
- data/app/helpers/dc_captcha_renderer.rb +100 -0
- data/app/helpers/dc_common_renderer.rb +132 -0
- data/app/helpers/dc_mail_renderer.rb +76 -0
- data/app/helpers/dc_menu_renderer.rb +143 -0
- data/app/helpers/dc_page_renderer.rb +80 -0
- data/app/helpers/dc_part_renderer.rb +162 -0
- data/app/helpers/dc_piece_renderer.rb +124 -0
- data/app/helpers/dc_poll_renderer.rb +219 -0
- data/app/helpers/dc_renderer.rb +56 -0
- data/app/helpers/dc_simple_menu_renderer.rb +244 -0
- data/app/helpers/drgcms_form_field.rb +863 -0
- data/app/models/__dc_global_data.rb +44 -0
- data/app/models/dc_ad.rb +52 -0
- data/app/models/dc_ad_stat.rb +34 -0
- data/app/models/dc_big_menu.rb +89 -0
- data/app/models/dc_big_table.rb +63 -0
- data/app/models/dc_big_table_locale.rb +35 -0
- data/app/models/dc_big_table_value.rb +38 -0
- data/app/models/dc_category.rb +48 -0
- data/app/models/dc_design.rb +48 -0
- data/app/models/dc_dummy.rb +30 -0
- data/app/models/dc_folder_permission.rb +43 -0
- data/app/models/dc_global_data.rb +44 -0
- data/app/models/dc_journal.rb +39 -0
- data/app/models/dc_key_value_store.rb +90 -0
- data/app/models/dc_link.rb +39 -0
- data/app/models/dc_mail.rb +64 -0
- data/app/models/dc_mail_address.rb +69 -0
- data/app/models/dc_mail_list.rb +48 -0
- data/app/models/dc_mail_list_member.rb +34 -0
- data/app/models/dc_menu.rb +59 -0
- data/app/models/dc_menu_item.rb +40 -0
- data/app/models/dc_page.rb +123 -0
- data/app/models/dc_part.rb +28 -0
- data/app/models/dc_permission.rb +58 -0
- data/app/models/dc_piece.rb +57 -0
- data/app/models/dc_policy.rb +94 -0
- data/app/models/dc_policy_role.rb +47 -0
- data/app/models/dc_policy_rule.rb +65 -0
- data/app/models/dc_poll.rb +46 -0
- data/app/models/dc_poll_item.rb +40 -0
- data/app/models/dc_sendmail.rb +48 -0
- data/app/models/dc_simple_menu.rb +58 -0
- data/app/models/dc_simple_menu_item.rb +39 -0
- data/app/models/dc_site.rb +92 -0
- data/app/models/dc_stat.rb +36 -0
- data/app/models/dc_user.rb +91 -0
- data/app/models/dc_user_role.rb +36 -0
- data/app/models/dc_visit.rb +35 -0
- data/app/views/cmsedit/_edit_stuff.html.erb +59 -0
- data/app/views/cmsedit/_edit_stuff.js.erb +6 -0
- data/app/views/cmsedit/_form.html.erb +21 -0
- data/app/views/cmsedit/_result.html.erb +20 -0
- data/app/views/cmsedit/edit.html.erb +6 -0
- data/app/views/cmsedit/error.html.erb +2 -0
- data/app/views/cmsedit/index.html.erb +6 -0
- data/app/views/cmsedit/new.html.erb +5 -0
- data/app/views/cmsedit/show.html.erb +21 -0
- data/app/views/dc_at_the_beginning/create.html.erb +9 -0
- data/app/views/dc_at_the_beginning/index.html.erb +19 -0
- data/app/views/dc_common/paste_clipboard.html.erb +17 -0
- data/app/views/dc_mail/subscribe.html.erb +7 -0
- data/app/views/dc_mail/unsubscribe.html.erb +19 -0
- data/app/views/layouts/cms.html.erb +17 -0
- data/app/views/layouts/cmsedit.html.erb +16 -0
- data/app/views/layouts/content.html.erb +16 -0
- data/config/initializers/kaminari_patch.rb +36 -0
- data/config/locales/datetimepicker.yml +13 -0
- data/config/locales/drgcms_en.yml +96 -0
- data/config/locales/drgcms_sl.yml +97 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/kaminari.yml +26 -0
- data/config/locales/models_en.yml +790 -0
- data/config/locales/models_sl.yml +805 -0
- data/config/locales/mongoid_sl.yml +60 -0
- data/config/locales/sl.yml +211 -0
- data/config/routes.rb +2 -0
- data/drg_cms.gemspec +28 -0
- data/lib/drg_cms.rb +45 -0
- data/lib/drg_cms/engine.rb +30 -0
- data/lib/drg_cms/version.rb +3 -0
- data/lib/tasks/at_the_beginning.yml +26 -0
- data/lib/tasks/dc_cleanup.rake +94 -0
- data/lib/tasks/drg_cms_tasks.rake +118 -0
- data/lib/tasks/send_mail.rake +253 -0
- data/lib/tasks/site_statistics.rake +80 -0
- data/test/drg_cms_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +375 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c72a699a0ff7d2c728862a4704654a2a23e826ba
|
4
|
+
data.tar.gz: 162273135c2be3ca8e6ed94a6ee56e00eec2255a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22893cf485499702a541f39f41bb480cae7244a742f05c2ed5c9c29c37a62ccde3bdf622dd8af22f2bc8f3925bb9c2f8c3e073d68d025c7c7d11a4240f82ec64
|
7
|
+
data.tar.gz: 9d9c0acaf0a7e8eaa27f945ad2e6fbe9e734cc23fc77282de50647bba0f80d98b416be80d993768f2149c3f7be198aefa0b7d07e34966f219afccacf9118d363
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012+ Damjan Rems
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'DrgCms'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
|
31
|
+
Rake::TestTask.new(:test) do |t|
|
32
|
+
t.libs << 'lib'
|
33
|
+
t.libs << 'test'
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
35
|
+
t.verbose = false
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
task :default => :test
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,449 @@
|
|
1
|
+
/*
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
|
24
|
+
/*******************************************************************
|
25
|
+
* Find and extract parameters value from url
|
26
|
+
*******************************************************************/
|
27
|
+
$.getUrlParam = function(name) {
|
28
|
+
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
29
|
+
return results[1] || 0;
|
30
|
+
};
|
31
|
+
|
32
|
+
/*******************************************************************
|
33
|
+
* Dump all attributes to console
|
34
|
+
*******************************************************************/
|
35
|
+
dumpAttributes = function(obj) {
|
36
|
+
console.log('Dumping attributes:');
|
37
|
+
$.each(obj.attributes, function() {
|
38
|
+
console.log(this.name,this.value);
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
/*******************************************************************
|
43
|
+
* Used for removing background from iframe element.
|
44
|
+
*******************************************************************/
|
45
|
+
remove_background_from_iframe = function(obj) {
|
46
|
+
var head = obj.head;
|
47
|
+
var css = '<style type="text/css">' +
|
48
|
+
'body{background: none;} ' +
|
49
|
+
'</style>';
|
50
|
+
$(head).append(css);
|
51
|
+
};
|
52
|
+
|
53
|
+
/*******************************************************************
|
54
|
+
* Activate jquery UI tooltip. This needs jquery.ui >= 1.9
|
55
|
+
*******************************************************************/
|
56
|
+
/*
|
57
|
+
$(function() {
|
58
|
+
$( document ).tooltip();
|
59
|
+
});
|
60
|
+
*/
|
61
|
+
|
62
|
+
/*******************************************************************
|
63
|
+
* Process json result from ajax call and update parts of document
|
64
|
+
*******************************************************************/
|
65
|
+
process_json_result = function(json) {
|
66
|
+
var c = '';
|
67
|
+
$.each(json, function(key, val) {
|
68
|
+
i = key.search('_');
|
69
|
+
if (i > 1) {
|
70
|
+
oper = key.substring(0,i);
|
71
|
+
what = key.substring(i+1,100);
|
72
|
+
switch (oper) {
|
73
|
+
/* update field */
|
74
|
+
case 'record':
|
75
|
+
$('#'+key).val(val);
|
76
|
+
break;
|
77
|
+
/* display message */
|
78
|
+
case 'msg':
|
79
|
+
selector = 'dc-form-' + what;
|
80
|
+
if ($('.'+selector).length == 0) {
|
81
|
+
val = '<div class="' + selector + '">' + val + '</div>';
|
82
|
+
$('.dc-title').after(val);
|
83
|
+
} else
|
84
|
+
$('.'+selector).html(val);
|
85
|
+
break;
|
86
|
+
/* update div */
|
87
|
+
case '#div+':
|
88
|
+
$('#'+what).append(val);
|
89
|
+
break;
|
90
|
+
case '#+div':
|
91
|
+
$('#'+what).prepend(val);
|
92
|
+
break;
|
93
|
+
case '#div':
|
94
|
+
$('#'+what).html(val);
|
95
|
+
break;
|
96
|
+
case '.div+':
|
97
|
+
$('.'+what).append(val);
|
98
|
+
break;
|
99
|
+
case '.+div':
|
100
|
+
$('.'+what).prepend(val);
|
101
|
+
break;
|
102
|
+
case '.div':
|
103
|
+
$('.'+what).html(val);
|
104
|
+
break;
|
105
|
+
/* goto url */
|
106
|
+
case 'url':
|
107
|
+
window.location.href = val;
|
108
|
+
break;
|
109
|
+
case 'window':
|
110
|
+
w = window.open(val, what);
|
111
|
+
w.focus();
|
112
|
+
break;
|
113
|
+
case 'reload':
|
114
|
+
location.reload();
|
115
|
+
break;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
});
|
119
|
+
};
|
120
|
+
|
121
|
+
/*******************************************************************
|
122
|
+
* Will reload window
|
123
|
+
*******************************************************************/
|
124
|
+
function dc_reload_window() {
|
125
|
+
location.reload();
|
126
|
+
}
|
127
|
+
|
128
|
+
/*******************************************************************
|
129
|
+
* Will scroll to position on the screen. This is replacement for
|
130
|
+
* location.hash, which doesn't work in Chrome.
|
131
|
+
*
|
132
|
+
* Thanks goes to: http://web-design-weekly.com/snippets/scroll-to-position-with-jquery/
|
133
|
+
*******************************************************************/
|
134
|
+
$.fn.dc_scroll_view = function () {
|
135
|
+
return this.each(function () {
|
136
|
+
$('html, body').animate({
|
137
|
+
scrollTop: $(this).offset().top - 50
|
138
|
+
}, 500);
|
139
|
+
});
|
140
|
+
};
|
141
|
+
|
142
|
+
/*******************************************************************
|
143
|
+
*
|
144
|
+
*******************************************************************/
|
145
|
+
$(document).ready( function() {
|
146
|
+
/*******************************************************************
|
147
|
+
* Register ad clicks
|
148
|
+
*******************************************************************/
|
149
|
+
$('a.link_to_track').click(function() {
|
150
|
+
$.post('/dc_common/ad_click', { id: this.id });
|
151
|
+
return true;
|
152
|
+
});
|
153
|
+
|
154
|
+
/*******************************************************************
|
155
|
+
* Popup or close CMS edit menu on icon click
|
156
|
+
*******************************************************************/
|
157
|
+
$('.drgcms_popmenu').bind('click',function(e) {
|
158
|
+
$(e.target).parents('dl:first').find('ul').toggleClass('div-hidden');
|
159
|
+
});
|
160
|
+
|
161
|
+
/*******************************************************************
|
162
|
+
* Popup CMS edit menu option clicked
|
163
|
+
*******************************************************************/
|
164
|
+
$('.drgcms_popmenu_item').bind('click',function(e) {
|
165
|
+
url = e.target.getAttribute("data-url");
|
166
|
+
$('#iframe_cms').attr('src', url);
|
167
|
+
// $('#iframe_cms').width(1000).height(1000);
|
168
|
+
// scroll to top of page and hide menu
|
169
|
+
window.scrollTo(0,0);
|
170
|
+
$(e.target).parents('dl:first').find('ul').toggleClass('div-hidden');
|
171
|
+
});
|
172
|
+
|
173
|
+
/*******************************************************************
|
174
|
+
* Sort action clicked on cmsedit
|
175
|
+
*******************************************************************/
|
176
|
+
$('.drgcms_sort').change( function(e) {
|
177
|
+
table = e.target.getAttribute("data-table");
|
178
|
+
sort = e.target.value;
|
179
|
+
e.target.value = null;
|
180
|
+
window.location.href = "/cmsedit?sort=" + sort + "&table=" + table;
|
181
|
+
});
|
182
|
+
|
183
|
+
/*******************************************************************
|
184
|
+
* Tab clicked on form. Hide old and show selected div.
|
185
|
+
*******************************************************************/
|
186
|
+
$('.dc-form-li').bind('click', function(e) {
|
187
|
+
/* find li with dc-form-li-selected class and remove it. This will deselect tab */
|
188
|
+
var old_id = null;
|
189
|
+
$(e.target).parents('ul').find('li').each( function() {
|
190
|
+
/* console.debug( $(this) ); */
|
191
|
+
if ($(this).hasClass('dc-form-li-selected')) {
|
192
|
+
/* ignore if tab is already selected */
|
193
|
+
if ($(this) !== $(e.target)) {
|
194
|
+
$(this).toggleClass('dc-form-li-selected');
|
195
|
+
$(e.target).toggleClass('dc-form-li-selected');
|
196
|
+
old_id = this.getAttribute("data-div");
|
197
|
+
}
|
198
|
+
return false;
|
199
|
+
}
|
200
|
+
|
201
|
+
}); /* show selected data div */
|
202
|
+
if (old_id !== null) {
|
203
|
+
$('#data_' + old_id).toggleClass('div-hidden');
|
204
|
+
$('#data_' + e.target.getAttribute("data-div")).toggleClass('div-hidden');
|
205
|
+
}
|
206
|
+
});
|
207
|
+
|
208
|
+
/*******************************************************************
|
209
|
+
* Resize iframe_cms to the size of its contents. Make at least 500 px hight
|
210
|
+
* unless on initial display.
|
211
|
+
*******************************************************************/
|
212
|
+
$('#iframe_cms').load( function() {
|
213
|
+
// alert('bla 1');
|
214
|
+
new_height = this.contentWindow.document.body.offsetHeight + 50;
|
215
|
+
if (new_height < 500 & new_height > 60) new_height = 500;
|
216
|
+
this.style.height = new_height + 'px';
|
217
|
+
remove_background_from_iframe(this.contentWindow.document);
|
218
|
+
$('#iframe_cms').dc_scroll_view();
|
219
|
+
});
|
220
|
+
|
221
|
+
/*******************************************************************
|
222
|
+
* Same goes for editiframe. Resize it + 30px
|
223
|
+
* unless on initial display with no data
|
224
|
+
*******************************************************************/
|
225
|
+
$('#iframe_edit').load( function() {
|
226
|
+
// console.log(this.contentWindow.document.body.offsetHeight);
|
227
|
+
if (this.contentWindow.document.body.offsetHeight > 10) {
|
228
|
+
this.style.height = (this.contentWindow.document.body.offsetHeight + 30) + 'px';
|
229
|
+
}
|
230
|
+
remove_background_from_iframe(this.contentWindow.document);
|
231
|
+
// scroll to it
|
232
|
+
$('#iframe_edit').dc_scroll_view();
|
233
|
+
});
|
234
|
+
|
235
|
+
/*******************************************************************
|
236
|
+
* Process Ajax call on cmsedit form actions
|
237
|
+
*******************************************************************/
|
238
|
+
$('.dc-link-ajax').bind('click', function(e) {
|
239
|
+
var target = e.target;
|
240
|
+
// if (e.target.src !== undefined) {
|
241
|
+
// target = e.target.parent(); // picture
|
242
|
+
// };
|
243
|
+
// dumpAttributes(target);
|
244
|
+
req = target.getAttribute("data-request");
|
245
|
+
/* Get some values from elements on the page: */
|
246
|
+
if (req == "script") {
|
247
|
+
eval (target.getAttribute("data-script"));
|
248
|
+
return false;
|
249
|
+
}
|
250
|
+
else if (req == "post") {
|
251
|
+
data = $('form').serialize();
|
252
|
+
alert(data);
|
253
|
+
}
|
254
|
+
else {
|
255
|
+
data = {};
|
256
|
+
req = 'get'; // by default
|
257
|
+
}
|
258
|
+
|
259
|
+
$('#dc-spinner').toggleClass('div-hidden');
|
260
|
+
$.ajax({
|
261
|
+
url: target.getAttribute("data-url"),
|
262
|
+
type: req,
|
263
|
+
dataType: "json",
|
264
|
+
data: data,
|
265
|
+
success: function(data) {
|
266
|
+
process_json_result(data);
|
267
|
+
$('#dc-spinner').toggleClass('div-hidden');
|
268
|
+
}
|
269
|
+
});
|
270
|
+
});
|
271
|
+
|
272
|
+
/*******************************************************************
|
273
|
+
* Animate button on click
|
274
|
+
******************************************************************
|
275
|
+
$('.xdc-action-menu li').mousedown( function() {
|
276
|
+
$(this).toggleClass('dc-animate-button');
|
277
|
+
});
|
278
|
+
|
279
|
+
******************************************************************
|
280
|
+
* Animate button on click
|
281
|
+
******************************************************************
|
282
|
+
$('.xdc-action-menu li').mouseup( function() {
|
283
|
+
$(this).toggleClass('dc-animate-button');
|
284
|
+
});
|
285
|
+
*/
|
286
|
+
/*******************************************************************
|
287
|
+
* Animate button on click
|
288
|
+
*******************************************************************/
|
289
|
+
$('.dc-animate').mousedown( function() {
|
290
|
+
$(this).toggleClass('dc-animate-button');
|
291
|
+
});
|
292
|
+
|
293
|
+
/*******************************************************************
|
294
|
+
* Animate button on click
|
295
|
+
*******************************************************************/
|
296
|
+
$('.dc-animate').mouseup( function() {
|
297
|
+
$(this).toggleClass('dc-animate-button');
|
298
|
+
});
|
299
|
+
|
300
|
+
/*******************************************************************
|
301
|
+
* App menu option clicked
|
302
|
+
*******************************************************************/
|
303
|
+
$('.app-menu-item a').bind('click', function(e) {
|
304
|
+
/* parent of a is li */
|
305
|
+
$(e.target).parents('li').each( function() {
|
306
|
+
/* for all li's in ul, deselect */
|
307
|
+
$(this).parents('ul').find('li').each( function() {
|
308
|
+
if ($(this).hasClass('app-menu-item-selected')) {
|
309
|
+
$(this).toggleClass('app-menu-item-selected');
|
310
|
+
}
|
311
|
+
});
|
312
|
+
/* select clicked li */
|
313
|
+
$(this).toggleClass('app-menu-item-selected');
|
314
|
+
});
|
315
|
+
});
|
316
|
+
|
317
|
+
/*******************************************************************
|
318
|
+
* Display spinner on link with spinner, submit link
|
319
|
+
*******************************************************************/
|
320
|
+
$('.dc-link-spinner').bind('click', function(e) {
|
321
|
+
$('#dc-spinner').toggleClass('div-hidden');
|
322
|
+
});
|
323
|
+
|
324
|
+
$('.dc-link-submit').bind('click', function(e) {
|
325
|
+
$('#dc-spinner').toggleClass('div-hidden');
|
326
|
+
});
|
327
|
+
|
328
|
+
/*******************************************************************
|
329
|
+
* Add button clicked while in edit. Create window dialog for adding new record
|
330
|
+
* into required table. This is helper scenario, when user is selecting
|
331
|
+
* data from with text_autocomplete and data doesn't exist in belongs_to table.
|
332
|
+
*******************************************************************/
|
333
|
+
$('.in-edit-add').bind('click', function(e) {
|
334
|
+
url = '/cmsedit/new?table=' + this.getAttribute("data-table");
|
335
|
+
/* I know. It doesn't work as expected. But it will do for now. */
|
336
|
+
w = window.open(url, '', 'chrome=yes,width=800,height=600,resizable,scrollbars=yes,status=1,centerscreen=yes,modal=yes');
|
337
|
+
w.focus();
|
338
|
+
});
|
339
|
+
|
340
|
+
/**********************************************************************
|
341
|
+
*
|
342
|
+
*
|
343
|
+
**********************************************************************/
|
344
|
+
$('#_filter_field').bind('change', function() {
|
345
|
+
if (this.value.length > 0) {
|
346
|
+
name = 'filter_' + this.value;
|
347
|
+
$(this).parents('form').find('span').each( function() {
|
348
|
+
/*
|
349
|
+
element = $(this).find(':first').attr('id');
|
350
|
+
sometimes it is the second element
|
351
|
+
if (element == nil) { element = $(this).find(':first').next().attr('id');}
|
352
|
+
*/
|
353
|
+
if ($(this).attr('id') == name) {
|
354
|
+
if ( $(this).hasClass('div-hidden') ) { $(this).toggleClass('div-hidden'); }
|
355
|
+
} else {
|
356
|
+
if ( !$(this).hasClass('div-hidden') ) { $(this).toggleClass('div-hidden'); }
|
357
|
+
}
|
358
|
+
});
|
359
|
+
}
|
360
|
+
});
|
361
|
+
|
362
|
+
/*******************************************************************
|
363
|
+
* It is not possible to attach any data to submit button except the text
|
364
|
+
* that is written on a button and it is therefore very hard to distinguish
|
365
|
+
* which button was pressed when more than one button is present on a form.
|
366
|
+
*
|
367
|
+
* The purpose of this trigger is to append data hidden in html5 data attributes
|
368
|
+
* to the form. We can now attach any kind of data to submit button and data
|
369
|
+
* will be passed as data[] parameters to controller.
|
370
|
+
*******************************************************************/
|
371
|
+
$('.dc-submit').bind('click', function() {
|
372
|
+
$.each(this.attributes, function() {
|
373
|
+
if (this.name.substring(0,5) == 'data-') {
|
374
|
+
$('<input>').attr({
|
375
|
+
type: 'hidden',
|
376
|
+
name: 'data[' + this.name.substring(5) + ']',
|
377
|
+
value: this.value
|
378
|
+
}).appendTo('form');
|
379
|
+
}
|
380
|
+
});
|
381
|
+
});
|
382
|
+
|
383
|
+
/* DOCUMENT INFO */
|
384
|
+
/*******************************************************************
|
385
|
+
* Popup or hide document information
|
386
|
+
*******************************************************************/
|
387
|
+
$('#dc-document-info').bind('click',function(e) {
|
388
|
+
popup = $(e.target).next();
|
389
|
+
popup.toggleClass('div-hidden');
|
390
|
+
if (!popup.hasClass('div-hidden')) {
|
391
|
+
var o = {
|
392
|
+
left: e.pageX - popup.width() - 10,
|
393
|
+
top: e.pageY - popup.height() - 20
|
394
|
+
};
|
395
|
+
popup.offset(o);
|
396
|
+
};
|
397
|
+
});
|
398
|
+
/*******************************************************************
|
399
|
+
* Just hide document information on click.
|
400
|
+
*******************************************************************/
|
401
|
+
$('#dc-document-info-popup').bind('click',function(e) {
|
402
|
+
// click on container (id)
|
403
|
+
if (e.target.id == 'dc-document-info-popup') {
|
404
|
+
$(e.target).toggleClass('div-hidden');
|
405
|
+
// click on text or picture. Hence hide parent
|
406
|
+
} else {
|
407
|
+
$(e.target).parent().toggleClass('div-hidden');
|
408
|
+
}
|
409
|
+
});
|
410
|
+
|
411
|
+
/*******************************************************************
|
412
|
+
* Force reload of parent page if this div appears
|
413
|
+
*******************************************************************/
|
414
|
+
$('#div-reload-parent').load( function() {
|
415
|
+
alert('div-reload-parent 1');
|
416
|
+
parent.location.href=parent.location.href
|
417
|
+
});
|
418
|
+
|
419
|
+
/*******************************************************************
|
420
|
+
* Force reload of parent page if this div appears
|
421
|
+
*******************************************************************/
|
422
|
+
$('#div-reload').load( function() {
|
423
|
+
alert('div-reload 1');
|
424
|
+
location.href=location.href
|
425
|
+
});
|
426
|
+
|
427
|
+
$('#div-reload-parent').bind('DOMNodeInserted DOMNodeRemoved', function() {
|
428
|
+
alert('div-reload-parent 2');
|
429
|
+
});
|
430
|
+
$('#div-reload').bind('DOMNodeInserted DOMNodeRemoved', function() {
|
431
|
+
alert('div-reload 2');
|
432
|
+
});
|
433
|
+
|
434
|
+
});
|
435
|
+
|
436
|
+
/*******************************************************************
|
437
|
+
* Catch ctrl+s key pressed and fire save form event. I press ctrl+s
|
438
|
+
* almost every minute. That was a lesson learned years ago when I lost
|
439
|
+
* few hours of work on computer lockup ;-(
|
440
|
+
*******************************************************************/
|
441
|
+
$(document).keydown( function(e) {
|
442
|
+
if ((e.which == '115' || e.which == '83' ) && (e.ctrlKey || e.metaKey))
|
443
|
+
{
|
444
|
+
e.preventDefault();
|
445
|
+
document.forms[0].submit();
|
446
|
+
return false;
|
447
|
+
}
|
448
|
+
return true;
|
449
|
+
});
|