diff options
Diffstat (limited to 'addons/project/static/src/js')
| -rw-r--r-- | addons/project/static/src/js/dropdown.js | 92 | ||||
| -rw-r--r-- | addons/project/static/src/js/project.js | 48 |
2 files changed, 140 insertions, 0 deletions
diff --git a/addons/project/static/src/js/dropdown.js b/addons/project/static/src/js/dropdown.js new file mode 100644 index 00000000000..54b61c5e9d0 --- /dev/null +++ b/addons/project/static/src/js/dropdown.js @@ -0,0 +1,92 @@ +/* ============================================================ + * bootstrap-dropdown.js v2.0.2 + * http://twitter.github.com/bootstrap/javascript.html#dropdowns + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function( $ ){ + + "use strict" + + /* DROPDOWN CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle="dropdown"]' + , Dropdown = function ( element ) { + var $el = $(element).on('click.dropdown.data-api', this.toggle) + $('html').on('click.dropdown.data-api', function () { + $el.parent().removeClass('open') + }) + } + + Dropdown.prototype = { + + constructor: Dropdown + + , toggle: function ( e ) { + var $this = $(this) + , selector = $this.attr('data-target') + , $parent + , isActive + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + $parent.length || ($parent = $this.parent()) + + isActive = $parent.hasClass('open') + + clearMenus() + !isActive && $parent.toggleClass('open') + + return false + } + + } + + function clearMenus() { + $(toggle).parent().removeClass('open') + } + + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + $.fn.dropdown = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('dropdown') + if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.dropdown.Constructor = Dropdown + + + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + $(function () { + $('html').on('click.dropdown.data-api', clearMenus) + $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) + }) + +}( window.jQuery );
\ No newline at end of file diff --git a/addons/project/static/src/js/project.js b/addons/project/static/src/js/project.js new file mode 100644 index 00000000000..09a7c9eb256 --- /dev/null +++ b/addons/project/static/src/js/project.js @@ -0,0 +1,48 @@ +openerp.project = function(openerp) { + openerp.web_kanban.ProjectKanban = openerp.web_kanban.KanbanRecord.include({ + bind_events: function() { + var self = this; + self._super(); + if(this.view.dataset.model == 'project.project') { + + /*set avatar title for members. + In many2many fields, returns only list of ids. + we can implement return value of m2m fields like [(1,"Adminstration"),...]. + */ + _.each($(this.$element).find('.project_avatar'),function(avatar){ + var dataset = new openerp.web.DataSetSearch(this, 'res.users', self.session.context, [['id','=',avatar.id]]); + dataset.read_slice(['name']).then(function(result){ + avatar.setAttribute("title",result[0].name) + }); + }); + + // set sequence like Tasks,Issues,Timesheets and Phases + var my_list = $("#list a") + my_list.sort(function (a, b) { + var aValue = parseInt(a.id); + var bValue = parseInt(b.id); + return aValue == bValue ? 0 : aValue < bValue ? -1 : 1; + }); + $('#list').replaceWith(my_list); + + // when vignette is clicked, it opens the first action in sequence + if (my_list.length != 0) { + var click_button = $(this.$element).find('.click_button') + click_button.attr('data-name', my_list[0].getAttribute('data-name')); + click_button.attr('data-type', "action"); + } + + /* set background color. + we can do other way to implement new widget. + because we need to rpc call for that. + */ + this.$element.find('.bgcolor').click(function(){ + var color = parseInt($(this).find('span').attr('class').split(' ')[0].substring(16)) + var color_class = $(this).find('span').attr('class').split(' ')[0] + $(this).closest('#oe_project_kanban_vignette').removeClass().addClass(color_class + ' oe_project_kanban_vignette'); + self.view.dataset.write(parseInt(this.id), {color:color}); + }); + } + } + }); +} |
