Moved back to javascript of bootstrap 2.0.4.

This commit is contained in:
Martin Edenhofer 2012-08-24 22:31:36 +02:00
parent 959faa6a94
commit b02ac54547
8 changed files with 144 additions and 218 deletions

View file

@ -560,7 +560,7 @@ class App.Controller extends Spine.Controller
clearInterval( @intervalID[interval_id] ) if @intervalID[interval_id]
interval: (action, interval, interval_id) =>
# check global var
if !@intervalID
@intervalID = {}
@ -587,12 +587,12 @@ class App.Controller extends Spine.Controller
delay: { show: 500, hide: 1200 },
# placement: 'bottom',
placement: position,
title: (e) =>
user_id = $(e).data('id')
title: ->
user_id = $(@).data('id')
user = App.User.find(user_id)
(user.firstname || '') + ' ' + (user.lastname || '')
content: (e) =>
user_id = $(e).data('id')
content: ->
user_id = $(@).data('id')
user = App.User.find(user_id)
# get display data
@ -608,7 +608,7 @@ class App.Controller extends Spine.Controller
App.view('user_info_small')(
user: user,
data: data,
)
)
)
userTicketPopups: (data) ->
@ -617,7 +617,7 @@ class App.Controller extends Spine.Controller
$('.popover-inner').parent().remove()
# get data
@tickets = {}
tickets = {}
App.Com.ajax(
type: 'GET',
url: '/ticket_customer',
@ -626,36 +626,37 @@ class App.Controller extends Spine.Controller
}
processData: true,
success: (data, status, xhr) =>
@tickets = data.tickets
tickets = data.tickets
)
if !data.position
data.position = 'left'
# show user popup
# show user popup
controller = @
$(data.selector).popover(
delay: { show: 500, hide: 5200 },
placement: data.position,
title: (e) =>
$(e).find('[title="*"]').val()
content: (e) =>
type = $(e).filter('[data-type]').data('type')
data = @tickets[type] || []
title: ->
$(@).find('[title="*"]').val()
content: ->
type = $(@).filter('[data-type]').data('type')
data = tickets[type] || []
for ticket in data
# set human time
ticket.humanTime = @humanTime(ticket.created_at)
ticket.humanTime = controller.humanTime(ticket.created_at)
# insert data
App.view('user_ticket_info_small')(
tickets: data,
)
)
)
loadCollection: (params) ->
# users
if params.type == 'User'
for user_id, user of params.data

View file

@ -42,14 +42,14 @@ class App.UserInfo extends App.Controller
user: App.User.find(user_id),
data: data,
)
@userTicketPopups(
selector: '.user-tickets',
user_id: user_id,
)
update: (e) =>
# update changes
note = $(e.target).parent().find('[data-type=edit]').val()
user = App.User.find(@user_id)

View file

@ -1,5 +1,5 @@
/* ============================================================
* bootstrap-dropdown.js v2.1.0
* bootstrap-dropdown.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================
* Copyright 2012 Twitter, Inc.
@ -26,7 +26,7 @@
/* DROPDOWN CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle=dropdown]'
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 () {
@ -41,82 +41,34 @@
, toggle: function (e) {
var $this = $(this)
, $parent
, selector
, isActive
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
selector = $this.attr('data-target')
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()
if (!isActive) {
$parent.toggleClass('open')
$this.focus()
}
if (!isActive) $parent.toggleClass('open')
return false
}
, keydown: function (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
if (!/(38|40|27)/.test(e.keyCode)) return
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
$items = $('[role=menu] li:not(.divider) a', $parent)
if (!$items.length) return
index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items
.eq(index)
.focus()
}
}
function clearMenus() {
getParent($(toggle))
}
function getParent($this) {
var selector = $this.attr('data-target')
, $parent
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
selector.replace(/\//, '\/\/')
$parent = $(selector)
$parent.length || ($parent = $this.parent())
return $parent
$(toggle).parent().removeClass('open')
}
@ -139,12 +91,10 @@
* =================================== */
$(function () {
$('html')
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
$('html').on('click.dropdown.data-api', clearMenus)
$('body')
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
})
}(window.jQuery);

View file

@ -1,5 +1,5 @@
/* =========================================================
* bootstrap-modal.js v2.1.0
* bootstrap-modal.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
@ -26,11 +26,10 @@
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (element, options) {
var Modal = function (content, options) {
this.options = options
this.$element = $(element)
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
}
Modal.prototype = {
@ -53,9 +52,8 @@
this.isShown = true
this.escape()
this.backdrop(function () {
escape.call(this)
backdrop.call(this, function () {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
@ -69,12 +67,7 @@
that.$element[0].offsetWidth // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false)
.focus()
that.enforceFocus()
that.$element.addClass('in')
transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
@ -98,98 +91,90 @@
$('body').removeClass('modal-open')
this.escape()
escape.call(this)
$(document).off('focusin.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
this.$element.removeClass('in')
$.support.transition && this.$element.hasClass('fade') ?
this.hideWithTransition() :
this.hideModal()
hideWithTransition.call(this) :
hideModal.call(this)
}
, enforceFocus: function () {
var that = this
$(document).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
})
}
/* MODAL PRIVATE METHODS
* ===================== */
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
hideModal.call(that)
})
}
function hideModal(that) {
this.$element
.hide()
.trigger('hidden')
backdrop.call(this)
}
function backdrop(callback) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)
if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
}
, escape: function () {
var that = this
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
}
}
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
, hideWithTransition: function () {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
that.hideModal()
}, 500)
this.$backdrop.addClass('in')
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
that.hideModal()
})
}
doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()
, hideModal: function (that) {
this.$element
.hide()
.trigger('hidden')
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
this.backdrop()
}
$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
removeBackdrop.call(this)
, removeBackdrop: function () {
this.$backdrop.remove()
this.$backdrop = null
}
} else if (callback) {
callback()
}
}
, backdrop: function (callback) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
function removeBackdrop() {
this.$backdrop.remove()
this.$backdrop = null
}
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)
if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
}
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
this.removeBackdrop()
} else if (callback) {
callback()
}
}
function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
}
}
@ -221,18 +206,12 @@
$(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this)
, href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
e.preventDefault()
$target
.modal(option)
.one('hide', function () {
$this.focus()
})
$target.modal(option)
})
})

View file

@ -1,5 +1,5 @@
/* ===========================================================
* bootstrap-popover.js v2.1.0
* bootstrap-popover.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#popovers
* ===========================================================
* Copyright 2012 Twitter, Inc.
@ -26,7 +26,7 @@
/* POPOVER PUBLIC CLASS DEFINITION
* =============================== */
var Popover = function (element, options) {
var Popover = function ( element, options ) {
this.init('popover', element, options)
}
@ -43,8 +43,8 @@
, title = this.getTitle()
, content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
$tip.removeClass('fade top bottom left right in')
}
@ -71,10 +71,6 @@
return this.$tip
}
, destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
@ -95,7 +91,6 @@
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right'
, trigger: 'click'
, content: ''
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
})

View file

@ -1,5 +1,5 @@
/* ========================================================
* bootstrap-tab.js v2.1.0
* bootstrap-tab.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2012 Twitter, Inc.
@ -26,7 +26,7 @@
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function (element) {
var Tab = function ( element ) {
this.element = $(element)
}

View file

@ -1,5 +1,5 @@
/* ===========================================================
* bootstrap-tooltip.js v2.1.0
* bootstrap-tooltip.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
* ===========================================================
@ -44,13 +44,11 @@
this.options = this.getOptions(options)
this.enabled = true
if (this.options.trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (this.options.trigger != 'manual') {
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
if (this.options.trigger != 'manual') {
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
}
this.options.selector ?
@ -150,11 +148,20 @@
}
}
, isHTML: function(text) {
// html string detection logic adapted from jQuery
return typeof text != 'string'
|| ( text.charAt(0) === "<"
&& text.charAt( text.length - 1 ) === ">"
&& text.length >= 3
) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
}
, setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
@ -178,8 +185,6 @@
$.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
$tip.remove()
return this
}
, fixTitle: function () {
@ -239,10 +244,6 @@
this[this.tip().hasClass('in') ? 'hide' : 'show']()
}
, destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
@ -269,7 +270,6 @@
, trigger: 'hover'
, title: ''
, delay: 0
, html: true
}
}(window.jQuery);

View file

@ -1,5 +1,5 @@
/* ===================================================
* bootstrap-transition.js v2.1.0
* bootstrap-transition.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
* Copyright 2012 Twitter, Inc.
@ -36,7 +36,8 @@
, transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'OTransition' : 'oTransitionEnd'
, 'msTransition' : 'MSTransitionEnd'
, 'transition' : 'transitionend'
}
, name