quick_script 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module QuickScript
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -31,6 +31,7 @@ History.getRelativeUrl = ->
31
31
  url = History.getState().url
32
32
  "/#{url.replace(History.getRootUrl(), '')}"
33
33
 
34
+ ## SELECTOPTS
34
35
  class @SelectOpts
35
36
  constructor : ->
36
37
  @options = []
@@ -122,6 +123,8 @@ class @Overlay
122
123
  constructor : ->
123
124
  @zindex = 100
124
125
  @notifyTimer = null
126
+ $(document).click ->
127
+ Overlay.removePopovers()
125
128
  Overlay.instance = new Overlay()
126
129
  Overlay.closeDialog = ->
127
130
  @remove('dialog')
@@ -131,7 +134,7 @@ Overlay.add = (vm, tmp, options, cls) ->
131
134
  cls = cls || ''
132
135
  options = {} if !options?
133
136
  #options['z-index'] = Overlay.instance.zindex + 10
134
- $('body').prepend("<div id='overlay-" + id + "' class='modal hide fade'><button class='close' data-bind='click : hideOverlay'>x</button><div class='content' data-bind=\"template: '" + template + "'\"></div></div>")
137
+ $('body').append("<div id='overlay-" + id + "' class='modal hide fade'><button class='close' data-bind='click : hideOverlay'>x</button><div class='content' data-bind=\"template: '" + template + "'\"></div></div>")
135
138
  #$('#overlay-' + id).css(options)
136
139
  #$('#overlay-' + id).addClass(cls)
137
140
  #$('#overlay-' + id).css({'margin-left' : -1 * $('#overlay-' + id).width() / 2})
@@ -187,7 +190,41 @@ Overlay.confirm = (msg, opts) ->
187
190
 
188
191
  Overlay.remove = (id) ->
189
192
  $('#overlay-' + id).modal('hide')
193
+ $('#popover-' + id).koClean().remove()
190
194
 
195
+ Overlay.removePopovers = ->
196
+ $('.popover').remove()
197
+
198
+ Overlay.popover = (el, tmp, vm, opts)->
199
+ id = vm.name
200
+ opts.placement = opts.placement || 'bottom'
201
+ $po = $("<div id='popover-#{id}' class='popover fade'><div class='arrow'></div><div class='popover-inner'><h3 class='popover-title'>#{opts.title}</h3><div class='popover-content' data-bind=\"template : '#{tmp}'\"></div></div></div>")
202
+ $po.remove().css({ top: 0, left: 0, display: 'block' }).prependTo(document.body)
203
+ $po.koBind(vm)
204
+ $po.click (ev)->
205
+ ev.stopPropagation()
206
+
207
+ pos = getElementPosition(el)
208
+ actualWidth = $po[0].offsetWidth
209
+ actualHeight = $po[0].offsetHeight
210
+ #console.log(actualWidth + ' ' + actualHeight)
211
+ #console.log(pos)
212
+
213
+ switch (opts.placement)
214
+ when 'bottom'
215
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
216
+ when 'top'
217
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
218
+ when 'left'
219
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
220
+ when 'right'
221
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
222
+
223
+ tp.display = 'block'
224
+ $po.css(tp).addClass(opts.placement).addClass('in')
225
+
226
+
227
+ ## TIMELENGTH
191
228
  class @TimeLength
192
229
  constructor : (@date1, @date2)->
193
230
  @date2 = new Date() unless @date2?
@@ -262,3 +299,9 @@ link_to_span = (text) ->
262
299
  fadeInElement = (elem) ->
263
300
  $(elem).hide().fadeIn()
264
301
 
302
+ @getElementPosition = (el)->
303
+ ret = $(el).offset()
304
+ ret.width = el.offsetWidth
305
+ ret.height = el.offsetHeight
306
+ return ret
307
+
@@ -230,22 +230,10 @@
230
230
  ko.bindingHandlers.tip =
231
231
  init : (element, valueAccessor) ->
232
232
  opts = valueAccessor()
233
- content = ko.utils.unwrapObservable(opts['content'])
234
- $(element).poshytip
235
- className: 'tip-twitter',
236
- showTimeout: 1,
237
- alignTo: 'target',
238
- alignX: 'center',
239
- offsetY: 5,
240
- allowTipHover: false,
241
- fade: false,
242
- slide: false,
243
- content: content
244
- update : (element, valueAccessor) ->
245
- opts = valueAccessor()
246
- content = ko.utils.unwrapObservable(opts['content'])
247
- $(element).poshytip('update', content)
248
-
233
+ $(element).tooltip
234
+ placement: opts.placement || 'bottom'
235
+ title: ->
236
+ ko.utils.unwrapObservable(opts.content)
249
237
 
250
238
  ko.absorbModel = (data, self) ->
251
239
  for prop, val of data
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alan Graham
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-09-19 00:00:00 -04:00
17
+ date: 2012-09-28 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20