quick_script 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ module QuickScript
9
9
  end
10
10
 
11
11
  def include_view_box
12
- raw "<div class='view-box' data-bind=\"template: {name : 'app-view', foreach : viewList() }\"></div>"
12
+ raw "<div data-bind=\"template: {name : getViewBoxTemplate}, attr : {class : 'view-box ' + transition.type}\"></div>"
13
13
  end
14
14
 
15
15
  def include_quick_script_init(app_model)
@@ -1,3 +1,3 @@
1
1
  module QuickScript
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -663,12 +663,21 @@ class @View
663
663
  @has_error = ko.computed (-> @error().length > 0), this
664
664
  @view = null
665
665
  @task = ko.observable(null)
666
+ @transition = {type : 'fade', opts : {'slide-left' : ko.observable(0)}}
666
667
  @init()
668
+ @setupViewBox()
667
669
  show : ->
668
670
  @is_visible(true)
669
671
  hide : ->
670
672
  @events.before_hide() if @events.before_hide?
671
673
  @is_visible(false)
674
+ setupViewBox : ->
675
+ if @transition.type == 'slide'
676
+ @task.subscribe (val)=>
677
+ if val != null
678
+ left = @getViewBoxIndex(val) * @transition.opts.width * -1
679
+ console.log(left)
680
+ @transition.opts['slide-left'](left)
672
681
  load : ->
673
682
  addView : (name, view_class, tpl) ->
674
683
  @views[name] = new view_class(name, this)
@@ -678,6 +687,8 @@ class @View
678
687
  , this
679
688
  @["select_task_#{name}"] = =>
680
689
  @selectView(name)
690
+ viewCount : ->
691
+ Object.keys(@views).length
681
692
  viewList : ->
682
693
  list = for name, view of @views
683
694
  view
@@ -699,6 +710,15 @@ class @View
699
710
  @task() == task
700
711
  getViewName : (view) ->
701
712
  view.templateID
713
+ getViewBoxTemplate : (view) ->
714
+ switch view.transition.type
715
+ when 'slide'
716
+ 'app-slide'
717
+ else
718
+ 'app-view'
719
+ getViewBoxIndex : (view_name) ->
720
+ arr = Object.keys(@views)
721
+ arr.indexAt(view_name)
702
722
  showAsOverlay : (tmp, opts, cls)=>
703
723
  Overlay.add(this, tmp, opts, cls)
704
724
  hideOverlay : =>
@@ -805,7 +825,8 @@ class @AppView extends @View
805
825
  @path = ko.observable(null)
806
826
  @path_parts = []
807
827
  @account_model = Model
808
- ko.addTemplate "app-view", "<div data-bind=\"fadeVisible : is_visible(), template : { name : getViewName }, attr : { class : view_name}\"></div>"
828
+ ko.addTemplate "app-view", "<div data-bind='foreach : viewList()'><div data-bind=\"fadeVisible : is_visible(), template : { name : getViewName }, attr : { id : templateID}\"></div></div>"
829
+ ko.addTemplate "app-slide", "<div data-bind=\"style : {width : transition.opts.width + 'px', 'overflow-x' : 'hidden'}\"><div class='view-slider' data-bind=\"style : {width : ((viewCount()+1) * transition.opts.width) + 'px', clear : 'both', 'margin-left' : transition.opts['slide-left']() + 'px'}\"><div data-bind='foreach : viewList()'><div data-bind=\"template : { name : getViewName }, attr : {id : templateID}, style : {width : owner.transition.opts.width + 'px', float : 'left'}\"></div></div></div><div style='clear: both;'></div></div>"
809
830
  super('app', null)
810
831
  @current_user = new @account_model()
811
832
  @is_logged_in = ko.dependentObservable ->
@@ -141,3 +141,5 @@
141
141
  +bold
142
142
  font-size: 20px
143
143
 
144
+ .view-slider
145
+ +animate(0.50s)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_script
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alan Graham
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-30 00:00:00 Z
18
+ date: 2012-06-03 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Framework for single-page web applications