From ae04f679246cce435be0e569a8ddd0127cfd83a9 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 8 May 2013 21:23:30 +0800 Subject: [PATCH] Announcement with UI to be modify and missing app_auth/module_auth UI --- app/assets/javascripts/back_end.js | 3 +- .../lib/bootstrap-datetimepicker.js | 1 + .../lib/datetimepicker/datetimepicker.js | 33 + app/assets/javascripts/lib/jquery.form.js | 980 ++++++++++++++++++ app/assets/javascripts/lib/modal-preview.js | 72 ++ app/controllers/admin/tags_controller.rb | 2 +- app/controllers/application_controller.rb | 4 +- app/controllers/orbit_backend_controller.rb | 4 +- app/helpers/default_index_helper.rb | 11 + app/helpers/orbit_backend_helper.rb | 302 +++++- .../default_index/_clear_filters.html.erb | 3 + .../default_index/_filter_categories.html.erb | 6 + .../default_index/_filter_status.html.erb | 9 + .../admin/default_index/_filter_tags.html.erb | 6 + app/views/admin/default_index/_index.html.erb | 68 ++ app/views/admin/tags/index.html.erb | 6 + app/views/layouts/back_end.html.erb | 7 +- config/locales/new_ui.en.yml | 21 +- .../back_end/bulletin_categorys_controller.rb | 152 +-- .../back_end/bulletins_controller.rb | 77 +- .../app/models/bulletin_category.rb | 2 + .../_bulletin_category.html.erb | 36 +- .../bulletin_categorys/_edit.html.erb | 10 + .../bulletin_categorys/_form.html.erb | 42 +- .../bulletin_categorys/_index.html.erb | 21 + .../back_end/bulletin_categorys/_new.html.erb | 10 + .../back_end/bulletin_categorys/create.js.erb | 2 - .../bulletin_categorys/destroy.js.erb | 1 - .../back_end/bulletin_categorys/edit.html.erb | 8 +- .../back_end/bulletin_categorys/edit.js.erb | 2 +- .../bulletin_categorys/index.html.erb | 44 +- .../back_end/bulletin_categorys/index.js.erb | 3 + .../back_end/bulletin_categorys/new.html.erb | 20 +- .../back_end/bulletin_categorys/new.js.erb | 2 +- .../back_end/bulletin_categorys/update.js.erb | 4 - .../bulletins/_bulletin_file_qe.html.erb | 51 - .../bulletins/_bulletin_link_qe.html.erb | 36 - .../back_end/bulletins/_bulletins.html.erb | 15 - .../bulletins/_clear_filters.html.erb | 3 - .../back_end/bulletins/_file.html.erb | 37 - .../bulletins/_filter_categories.html.erb | 6 - .../bulletins/_filter_status.html.erb | 9 - .../back_end/bulletins/_filter_tags.html.erb | 6 - .../back_end/bulletins/_form.html.erb | 569 +++++----- .../back_end/bulletins/_form_back.html.erb | 305 ++++++ .../bulletins/_form_bulletin_file.html.erb | 76 -- .../bulletins/_form_bulletin_link.html.erb | 48 - .../back_end/bulletins/_form_file.html.erb | 51 + .../back_end/bulletins/_form_link.html.erb | 23 + .../bulletins/_list_bulletin_file.html.erb | 20 - .../bulletins/_list_bulletin_link.html.erb | 15 - .../back_end/bulletins/_quick_edit.html.erb | 10 - .../bulletins/_quick_edit_basic.html.erb | 64 -- .../bulletins/_quick_edit_files.html.erb | 26 - .../bulletins/_quick_edit_links.html.erb | 27 - .../bulletins/_quick_edit_picture.html.erb | 25 - .../bulletins/_quick_edit_tags.html.erb | 15 - .../back_end/bulletins/_sort_headers.html.erb | 8 - .../bulletins/create_bulletin_file.html.erb | 1 - .../bulletins/create_bulletin_file.js.erb | 2 - .../bulletins/create_bulletin_link.js.erb | 2 - .../back_end/bulletins/edit.html.erb | 19 +- .../back_end/bulletins/file_quick_add.js.erb | 1 - .../back_end/bulletins/file_quick_edit.js.erb | 1 - .../back_end/bulletins/index.html.erb | 82 +- .../back_end/bulletins/index.js.erb | 7 - .../back_end/bulletins/link_quick_add.js.erb | 1 - .../back_end/bulletins/link_quick_edit.js.erb | 1 - .../back_end/bulletins/load_quick_edit.js.erb | 2 - .../back_end/bulletins/new.html.erb | 10 +- .../bulletins/update_bulletin_file.js.erb | 2 - .../bulletins/update_bulletin_link.js.erb | 2 - .../announcement/config/routes.rb | 3 + vendor/built_in_modules/announcement/init.rb | 2 + vendor/built_in_modules/archive/init.rb | 2 + vendor/built_in_modules/calendar/init.rb | 2 + vendor/built_in_modules/faq/init.rb | 2 + vendor/built_in_modules/gallery/init.rb | 2 + vendor/built_in_modules/web_resource/init.rb | 2 + 79 files changed, 2376 insertions(+), 1191 deletions(-) create mode 100644 app/assets/javascripts/lib/datetimepicker/datetimepicker.js create mode 100644 app/assets/javascripts/lib/jquery.form.js create mode 100644 app/assets/javascripts/lib/modal-preview.js create mode 100644 app/helpers/default_index_helper.rb create mode 100644 app/views/admin/default_index/_clear_filters.html.erb create mode 100644 app/views/admin/default_index/_filter_categories.html.erb create mode 100644 app/views/admin/default_index/_filter_status.html.erb create mode 100644 app/views/admin/default_index/_filter_tags.html.erb create mode 100644 app/views/admin/default_index/_index.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_edit.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_index.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_new.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/create.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/update.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file_qe.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_clear_filters.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_file.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_categories.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_status.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_tags.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_back.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_file.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_link.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_link.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_basic.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_links.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_tags.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_link.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_add.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_edit.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_add.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/load_quick_edit.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_file.js.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_link.js.erb diff --git a/app/assets/javascripts/back_end.js b/app/assets/javascripts/back_end.js index affd9a06a..0b2af80ec 100644 --- a/app/assets/javascripts/back_end.js +++ b/app/assets/javascripts/back_end.js @@ -2,4 +2,5 @@ //= require lib/footable-0.1.js //= require lib/all-list //= require lib/jquery.fastLiveFilter.js -//= require lib/checkbox.card.js \ No newline at end of file +//= require lib/checkbox.card.js +//= require lib/jquery.form.js \ No newline at end of file diff --git a/app/assets/javascripts/lib/bootstrap-datetimepicker.js b/app/assets/javascripts/lib/bootstrap-datetimepicker.js index 8bd2ae807..4c5e6c9d0 100644 --- a/app/assets/javascripts/lib/bootstrap-datetimepicker.js +++ b/app/assets/javascripts/lib/bootstrap-datetimepicker.js @@ -698,6 +698,7 @@ clear: function(e) { if (this.isInput) this.$element.val(null); else this.$element.find('input').val(null); + this.notifyChange(); }, showMode: function(dir) { diff --git a/app/assets/javascripts/lib/datetimepicker/datetimepicker.js b/app/assets/javascripts/lib/datetimepicker/datetimepicker.js new file mode 100644 index 000000000..83408a24d --- /dev/null +++ b/app/assets/javascripts/lib/datetimepicker/datetimepicker.js @@ -0,0 +1,33 @@ +$(document).ready(function(){ + + $('.date_picker').datetimepicker({ + pickTime: false + }); + + $('.default_picker').datetimepicker(); + + $('.time_picker').datetimepicker({ + pickDate: false + }); + + $('.separated_picker div').on("changeDate",function(){ + if ($(this).hasClass('date_picker')) + { + if ($(this).find('input').val() && $(this).siblings('div').css('pointer-events')) + { + $(this).siblings('div').css('pointer-events', ''); + } + else + { + $(this).siblings('div').find('input').val(null); + $(this).siblings('div').css('pointer-events', 'none'); + } + } + $(this).siblings('input').val($(this).find('input').val() + ' ' + $(this).siblings('div').find('input').val()); + }); + + // $('.date_picker').on("changeDate",function(){ + // $(this).find('input').val(''); + // }); + +}); \ No newline at end of file diff --git a/app/assets/javascripts/lib/jquery.form.js b/app/assets/javascripts/lib/jquery.form.js new file mode 100644 index 000000000..7f11d05c8 --- /dev/null +++ b/app/assets/javascripts/lib/jquery.form.js @@ -0,0 +1,980 @@ +/*! + * jQuery Form Plugin + * version: 2.94 (13-DEC-2011) + * @requires jQuery v1.3.2 or later + * + * Examples and documentation at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ +;(function($) { + +/* + Usage Note: + ----------- + Do not use both ajaxSubmit and ajaxForm on the same form. These + functions are intended to be exclusive. Use ajaxSubmit if you want + to bind your own submit handler to the form. For example, + + $(document).ready(function() { + $('#myForm').bind('submit', function(e) { + e.preventDefault(); // <-- important + $(this).ajaxSubmit({ + target: '#output' + }); + }); + }); + + Use ajaxForm when you want the plugin to manage all the event binding + for you. For example, + + $(document).ready(function() { + $('#myForm').ajaxForm({ + target: '#output' + }); + }); + + When using ajaxForm, the ajaxSubmit function will be invoked for you + at the appropriate time. +*/ + +/** + * ajaxSubmit() provides a mechanism for immediately submitting + * an HTML form using AJAX. + */ +$.fn.ajaxSubmit = function(options) { + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + if (!this.length) { + log('ajaxSubmit: skipping submit process - no element selected'); + return this; + } + + var method, action, url, $form = this; + + if (typeof options == 'function') { + options = { success: options }; + } + + method = this.attr('method'); + action = this.attr('action'); + url = (typeof action === 'string') ? $.trim(action) : ''; + url = url || window.location.href || ''; + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + + options = $.extend(true, { + url: url, + success: $.ajaxSettings.success, + type: method || 'GET', + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' + }, options); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + this.trigger('form-pre-serialize', [this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; + } + + // provide opportunity to alter form data before it is serialized + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; + } + + var traditional = options.traditional; + if ( traditional === undefined ) { + traditional = $.ajaxSettings.traditional; + } + + var qx,n,v,a = this.formToArray(options.semantic); + if (options.data) { + options.extraData = options.data; + qx = $.param(options.data, traditional); + } + + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + + // fire vetoable 'validate' event + this.trigger('form-submit-validate', [a, this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); + return this; + } + + var q = $.param(a, traditional); + if (qx) { + q = ( q ? (q + '&' + qx) : qx ); + } + if (options.type.toUpperCase() == 'GET') { + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else { + options.data = q; // data is the query string for 'post' + } + + var callbacks = []; + if (options.resetForm) { + callbacks.push(function() { $form.resetForm(); }); + } + if (options.clearForm) { + callbacks.push(function() { $form.clearForm(options.includeHidden); }); + } + + // perform a load on the target only if dataType is not provided + if (!options.dataType && options.target) { + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + var fn = options.replaceTarget ? 'replaceWith' : 'html'; + $(options.target)[fn](data).each(oldSuccess, arguments); + }); + } + else if (options.success) { + callbacks.push(options.success); + } + + options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg + var context = options.context || options; // jQuery 1.4+ supports scope context + for (var i=0, max=callbacks.length; i < max; i++) { + callbacks[i].apply(context, [data, status, xhr || $form, $form]); + } + }; + + // are there files to upload? + var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) + var hasFileInputs = fileInputs.length > 0; + var mp = 'multipart/form-data'; + var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + + var fileAPI = !!(hasFileInputs && fileInputs.get(0).files && window.FormData); + log("fileAPI :" + fileAPI); + var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; + + // options.iframe allows user to force iframe mode + // 06-NOV-09: now defaulting to iframe mode if file input is detected + if (options.iframe !== false && (options.iframe || shouldUseFrame)) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if (options.closeKeepAlive) { + $.get(options.closeKeepAlive, function() { + fileUploadIframe(a); + }); + } + else { + fileUploadIframe(a); + } + } + else if ((hasFileInputs || multipart) && fileAPI) { + options.progress = options.progress || $.noop; + fileUploadXhr(a); + } + else { + $.ajax(options); + } + + // fire 'notify' event + this.trigger('form-submit-notify', [this, options]); + return this; + + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) + function fileUploadXhr(a) { + var formdata = new FormData(); + + for (var i=0; i < a.length; i++) { + if (a[i].type == 'file') + continue; + formdata.append(a[i].name, a[i].value); + } + + $form.find('input:file:enabled').each(function(){ + var name = $(this).attr('name'), files = this.files; + if (name) { + for (var i=0; i < files.length; i++) + formdata.append(name, files[i]); + } + }); + + if (options.extraData) { + for (var k in options.extraData) + formdata.append(k, options.extraData[k]) + } + + options.data = null; + + var s = $.extend(true, {}, $.ajaxSettings, options, { + contentType: false, + processData: false, + cache: false, + type: 'POST' + }); + + s.context = s.context || s; + + s.data = null; + var beforeSend = s.beforeSend; + s.beforeSend = function(xhr, o) { + o.data = formdata; + if(xhr.upload) { // unfortunately, jQuery doesn't expose this prop (http://bugs.jquery.com/ticket/10190) + xhr.upload.onprogress = function(event) { + o.progress(event.position, event.total); + }; + } + if(beforeSend) + beforeSend.call(o, xhr, options); + }; + $.ajax(s); + } + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUploadIframe(a) { + var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; + var useProp = !!$.fn.prop; + + if (a) { + if ( useProp ) { + // ensure that every serialized input is still enabled + for (i=0; i < a.length; i++) { + el = $(form[a[i].name]); + el.prop('disabled', false); + } + } else { + for (i=0; i < a.length; i++) { + el = $(form[a[i].name]); + el.removeAttr('disabled'); + } + }; + } + + if ($(':input[name=submit],:input[id=submit]', form).length) { + // if there is an input with a name or id of 'submit' then we won't be + // able to invoke the submit fn on the form (at least not x-browser) + alert('Error: Form elements must not have name or id of "submit".'); + return; + } + + s = $.extend(true, {}, $.ajaxSettings, options); + s.context = s.context || s; + id = 'jqFormIO' + (new Date().getTime()); + if (s.iframeTarget) { + $io = $(s.iframeTarget); + n = $io.attr('name'); + if (n == null) + $io.attr('name', id); + else + id = n; + } + else { + $io = $('