copy_tuner_client 0.1.1.beta7 → 0.1.1.beta8

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.2
5
5
 
6
6
  gemfile:
7
- - gemfiles/2.3.gemfile
8
- - gemfiles/3.0.gemfile
9
- - gemfiles/3.1.gemfile
7
+ - gemfiles/3.2.gemfile
8
+ - gemfiles/4.0.gemfile
9
+ - gemfiles/4.1.gemfile
data/Appraisals CHANGED
@@ -1,15 +1,12 @@
1
- appraise '2.3' do
2
- gem 'rails', '2.3.16'
1
+ appraise '3.2' do
2
+ gem 'rails', '3.2.19'
3
3
  end
4
4
 
5
- appraise '3.0' do
6
- gem 'rails', '3.0.20'
5
+ appraise '4.0' do
6
+ gem 'rails', '4.0.8'
7
7
  end
8
8
 
9
- appraise '3.1' do
10
- gem 'rails', '3.1.10'
11
- gem 'jquery-rails'
12
- gem 'uglifier'
13
- gem 'sass-rails'
14
- gem 'coffee-rails'
9
+
10
+ appraise '4.1' do
11
+ gem 'rails', '4.1.4'
15
12
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copy_tuner_client (0.1.1.beta7)
4
+ copy_tuner_client (0.1.1.beta8)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
data/README.md CHANGED
@@ -4,9 +4,23 @@ CopyTuner Client
4
4
  [TODO] Write After
5
5
 
6
6
 
7
+
8
+ Development
9
+ =================
10
+
7
11
  ## Spec
8
12
 
13
+ ### default spec
14
+
15
+ $ bundle exec rake
16
+
9
17
  ### Appraisal for Multi Version Rails spec
10
18
 
11
- rake appraisal:install
12
- rake appraisal
19
+ $ bundle exec rake appraisal:install
20
+ $ bundle exec rake appraisal
21
+
22
+ ## release gem
23
+
24
+ $ bundle exec rake build # build gem to pkg/ dir
25
+ $ bundle exec rake install # install to local gem
26
+ $ bundle exec rake release # release gem to rubygems.org
@@ -1,86 +1,85 @@
1
- window.Xray = {}
1
+ window.Copyray = {}
2
2
  return unless $ = window.jQuery
3
3
 
4
- # Max CSS z-index. The overlay and xray bar use this.
4
+ # Max CSS z-index. The overlay and copyray bar use this.
5
5
  MAX_ZINDEX = 2147483647
6
6
 
7
- # Initialize Xray. Called immediately, but some setup is deferred until DOM ready.
8
- Xray.init = do ->
9
- return if Xray.initialized
10
- Xray.initialized = true
7
+ # Initialize Copyray. Called immediately, but some setup is deferred until DOM ready.
8
+ Copyray.init = do ->
9
+ return if Copyray.initialized
10
+ Copyray.initialized = true
11
11
 
12
12
  is_mac = navigator.platform.toUpperCase().indexOf('MAC') isnt -1
13
13
 
14
14
  # Register keyboard shortcuts
15
15
  $(document).keydown (e) ->
16
- # cmd+shift+x on Mac, ctrl+shift+x on other platforms
17
- if (is_mac and e.metaKey or !is_mac and e.ctrlKey) and e.shiftKey and e.keyCode is 88
18
- if Xray.isShowing then Xray.hide() else Xray.show()
19
- if Xray.isShowing and e.keyCode is 27 # esc
20
- Xray.hide()
16
+ # cmd + shift + k
17
+ if (is_mac and e.metaKey or !is_mac and e.ctrlKey) and e.shiftKey and e.keyCode is 75
18
+ if Copyray.isShowing then Copyray.hide() else Copyray.show()
19
+ if Copyray.isShowing and e.keyCode is 27 # esc
20
+ Copyray.hide()
21
21
 
22
22
  $ ->
23
23
  # Instantiate the overlay singleton.
24
- new Xray.Overlay
24
+ new Copyray.Overlay
25
25
  # Go ahead and do a pass on the DOM to find templates.
26
- Xray.findTemplates()
26
+ Copyray.findBlurbs()
27
27
  # Ready to rock.
28
- console?.log "Ready to Xray. Press #{if is_mac then 'cmd+shift+x' else 'ctrl+shift+x'} to scan your UI."
28
+ console?.log "Ready to Copyray. Press #{if is_mac then 'cmd+shift+k' else 'ctrl+shift+k'} to scan your UI."
29
29
 
30
- # Returns all currently created Xray.Specimen objects.
31
- Xray.specimens = ->
32
- Xray.ViewSpecimen.all.concat Xray.TemplateSpecimen.all
30
+ # Returns all currently created Copyray.Specimen objects.
31
+ Copyray.specimens = ->
32
+ Copyray.BlurbSpecimen.all
33
33
 
34
34
  # Looks up the stored constructor info
35
- Xray.constructorInfo = (constructor) ->
36
- if window.XrayPaths
37
- for own info, func of window.XrayPaths
35
+ Copyray.constructorInfo = (constructor) ->
36
+ if window.CopyrayPaths
37
+ for own info, func of window.CopyrayPaths
38
38
  return JSON.parse(info) if func == constructor
39
39
  null
40
40
 
41
- # Scans the document for templates, creating Xray.TemplateSpecimens for them.
42
- Xray.findTemplates = -> util.bm 'findTemplates', ->
43
- # Find all <!-- XRAY START ... --> comments
41
+ # Scans the document for blurbs, creating Copyray.BlurbSpecimen for them.
42
+ Copyray.findBlurbs = -> util.bm 'findBlurbs', ->
43
+ # Find all <!-- COPYRAY START ... --> comments
44
44
  comments = $('*:not(iframe,script)').contents().filter ->
45
- this.nodeType == 8 and this.data[0..9] == "XRAY START"
45
+ this.nodeType == 8 and this.data[0..12] == "COPYRAY START"
46
46
 
47
- # Find the <!-- XRAY END ... --> comment for each. Everything between the
48
- # start and end comment becomes the contents of an Xray.TemplateSpecimen.
47
+ # Find the <!-- COPYRAY END ... --> comment for each. Everything between the
49
48
  for comment in comments
50
- [_, id, path, url] = comment.data.match(/^XRAY START (\d+) (\S*) (\S*)/)
51
- $templateContents = new jQuery
49
+ [_, id, path, url] = comment.data.match(/^COPYRAY START (\d+) (\S*) (\S*)/)
50
+ $blurbContents = new jQuery
52
51
  el = comment.nextSibling
53
- until !el or (el.nodeType == 8 and el.data == "XRAY END #{id}")
52
+ until !el or (el.nodeType == 8 and el.data == "COPYRAY END #{id}")
54
53
  if el.nodeType == 1 and el.tagName != 'SCRIPT'
55
- $templateContents.push el
54
+ $blurbContents.push el
56
55
  el = el.nextSibling
57
- # Remove XRAY template comments from the DOM.
56
+ # Remove COPYRAY template comments from the DOM.
58
57
  el.parentNode.removeChild(el) if el?.nodeType == 8
59
58
  comment.parentNode.removeChild(comment)
60
59
  # Add the template specimen
61
- Xray.TemplateSpecimen.add $templateContents,
60
+ Copyray.BlurbSpecimen.add $blurbContents,
62
61
  name: path.split('/').slice(-1)[0]
63
62
  path: path
64
63
  url: url
65
64
 
66
- # Open the given filesystem path by calling out to Xray's server.
67
- Xray.open = (url) ->
65
+ # Open the given filesystem path by calling out to Copyray's server.
66
+ Copyray.open = (url) ->
68
67
  window.open(url, null, 'width=700, height=500')
69
68
 
70
- # Show the Xray overlay
71
- Xray.show = (type = null) ->
72
- Xray.Overlay.instance().show(type)
69
+ # Show the Copyray overlay
70
+ Copyray.show = (type = null) ->
71
+ Copyray.Overlay.instance().show(type)
73
72
 
74
- # Hide the Xray overlay
75
- Xray.hide = ->
76
- Xray.Overlay.instance().hide()
73
+ # Hide the Copyray overlay
74
+ Copyray.hide = ->
75
+ Copyray.Overlay.instance().hide()
77
76
 
78
- Xray.toggleSettings = ->
79
- Xray.Overlay.instance().settings.toggle()
77
+ Copyray.toggleSettings = ->
78
+ Copyray.Overlay.instance().settings.toggle()
80
79
 
81
- # Wraps a DOM element that Xray is tracking. This is subclassed by
82
- # Xray.TemplateSpecimen and Xray.ViewSpecimen.
83
- class Xray.Specimen
80
+ # Wraps a DOM element that Copyray is tracking. This is subclassed by
81
+ # Copyray.Blurbsspecimen
82
+ class Copyray.Specimen
84
83
  @add: (el, info = {}) ->
85
84
  @all.push new this(el, info)
86
85
 
@@ -112,7 +111,7 @@ class Xray.Specimen
112
111
 
113
112
  makeBox: ->
114
113
  @bounds = util.computeBoundingBox(@$contents)
115
- @$box = $("<div class='xray-specimen #{@constructor.name}'>").css(@bounds)
114
+ @$box = $("<div class='copyray-specimen #{@constructor.name}'>").css(@bounds)
116
115
 
117
116
  # If the element is fixed, override the computed position with the fixed one.
118
117
  if @$contents.css('position') == 'fixed'
@@ -121,58 +120,35 @@ class Xray.Specimen
121
120
  top : @$contents.css('top')
122
121
  left : @$contents.css('left')
123
122
 
124
- @$box.click => Xray.open @url + '/blurbs/' + @path + '/edit'
123
+ @$box.click => Copyray.open @url + '/blurbs/' + @path + '/edit'
125
124
  @$box.append @makeLabel
126
125
 
127
126
  makeLabel: =>
128
- $("<div class='xray-specimen-handle #{@constructor.name}'>").append(@name)
127
+ $("<div class='copyray-specimen-handle #{@constructor.name}'>").append(@name)
129
128
 
130
-
131
- # Wraps elements that constitute a Javascript "view" object, e.g.
132
- # Backbone.View.
133
- class Xray.ViewSpecimen extends Xray.Specimen
134
- @all = []
135
-
136
-
137
- # Wraps elements that were rendered by a template, e.g. a Rails partial or
138
- # a client-side rendered JS template.
139
- class Xray.TemplateSpecimen extends Xray.Specimen
129
+ # copy-tuner blurbs
130
+ class Copyray.BlurbSpecimen extends Copyray.Specimen
140
131
  @all = []
141
132
 
142
-
143
- # Singleton class for the Xray "overlay" invoked by the keyboard shortcut
144
- class Xray.Overlay
133
+ # Singleton class for the Copyray "overlay" invoked by the keyboard shortcut
134
+ class Copyray.Overlay
145
135
  @instance: ->
146
136
  @singletonInstance ||= new this
147
137
 
148
138
  constructor: ->
149
- Xray.Overlay.singletonInstance = this
150
- @bar = new Xray.Bar('#xray-bar')
151
- @settings = new Xray.Settings('#xray-settings')
139
+ Copyray.Overlay.singletonInstance = this
140
+ @$overlay = $('<div id="copyray-overlay">')
152
141
  @shownBoxes = []
153
- @$overlay = $('<div id="xray-overlay">')
154
142
  @$overlay.click => @hide()
155
143
 
156
144
  show: (type = null) ->
157
145
  @reset()
158
- Xray.isShowing = true
146
+ Copyray.isShowing = true
159
147
  util.bm 'show', =>
160
- @bar.$el.find('#xray-bar-togglers .xray-bar-btn').removeClass('active')
161
148
  unless @$overlay.is(':visible')
162
149
  $('body').append @$overlay
163
- @bar.show()
164
- switch type
165
- when 'templates'
166
- Xray.findTemplates()
167
- specimens = Xray.TemplateSpecimen.all
168
- @bar.$el.find('.xray-bar-templates-toggler').addClass('active')
169
- when 'views'
170
- specimens = Xray.ViewSpecimen.all
171
- @bar.$el.find('.xray-bar-views-toggler').addClass('active')
172
- else
173
- Xray.findTemplates()
174
- specimens = Xray.specimens()
175
- @bar.$el.find('.xray-bar-all-toggler').addClass('active')
150
+ Copyray.findBlurbs()
151
+ specimens = Copyray.specimens()
176
152
  for element in specimens
177
153
  continue unless element.isVisible()
178
154
  element.makeBox()
@@ -188,62 +164,9 @@ class Xray.Overlay
188
164
  @shownBoxes = []
189
165
 
190
166
  hide: ->
191
- Xray.isShowing = false
167
+ Copyray.isShowing = false
192
168
  @$overlay.detach()
193
169
  @reset()
194
- @bar.hide()
195
-
196
-
197
- # The Xray bar shows controller, action, and view information, and has
198
- # toggle buttons for showing the different types of specimens in the overlay.
199
- class Xray.Bar
200
- constructor: (el) ->
201
- @$el = $(el)
202
- @$el.css(zIndex: MAX_ZINDEX)
203
- @$el.find('#xray-bar-controller-path .xray-bar-btn').click ->
204
- Xray.open($(this).attr('data-path'))
205
- @$el.find('.xray-bar-all-toggler').click -> Xray.show()
206
- @$el.find('.xray-bar-templates-toggler').click -> Xray.show('templates')
207
- @$el.find('.xray-bar-views-toggler').click -> Xray.show('views')
208
- @$el.find('.xray-bar-settings-btn').click -> Xray.toggleSettings()
209
-
210
- show: ->
211
- @$el.show()
212
- @originalPadding = parseInt $('html').css('padding-bottom')
213
- if @originalPadding < 40
214
- $('html').css paddingBottom: 40
215
-
216
- hide: ->
217
- @$el.hide()
218
- $('html').css paddingBottom: @originalPadding
219
-
220
-
221
- class Xray.Settings
222
- constructor: (el) ->
223
- @$el = $(el)
224
- @$el.find('form').submit @save
225
-
226
- toggle: =>
227
- @$el.toggle()
228
-
229
- save: (e) =>
230
- e.preventDefault()
231
- editor = @$el.find('#xray-editor-input').val()
232
- $.ajax
233
- url: '/_xray/config'
234
- type: 'POST'
235
- data: {editor: editor}
236
- success: => @displayUpdateMsg(true)
237
- error: => @displayUpdateMsg(false)
238
-
239
- displayUpdateMsg: (success) =>
240
- if success
241
- $msg = $("<span class='xray-settings-success xray-settings-update-msg'>Success!</span>")
242
- else
243
- $msg = $("<span class='xray-settings-error xray-settings-update-msg'>Uh oh, something went wrong!</span>")
244
- @$el.append($msg)
245
- $msg.delay(2000).fadeOut(500, => $msg.remove(); @toggle())
246
-
247
170
 
248
171
  # Utility methods.
249
172
  util =