material_raingular-ace 0.0.2.alpha → 0.0.3.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79c3e091965542e4c713fc22b624df3ffbb22147
4
- data.tar.gz: d4e2dce864d3cff414dc63ec0e478dac704be59a
3
+ metadata.gz: 145c26761fe98f3ea59b6fc7081ad306eeb49692
4
+ data.tar.gz: df31cfc7bc874828d226147c9cf36b3388cd2760
5
5
  SHA512:
6
- metadata.gz: b9776f770cdf678c98a91bcbf29e3baf13f495ecc0595810b6b7660a156cbeb3d352a3d99bb9454a225bb5262eaaa4f4754c54f94387a81035262859db26c0b3
7
- data.tar.gz: a2179bb4118415793e15a7d77a797a34c5ba56c155f24bc643b6bf80bb059161e7b9423631900f8db08642a4b4a0c6572fffe62420beb6e7915ef46eb1b6c1a4
6
+ metadata.gz: 5d2a7eb070b4598d6449c7417306055a05d442a68335e918946da21502801a692bb1e1c17e6348929d753c9faace79c7ccd0479dc95b5bc49d9a3e1c3a49ea1c
7
+ data.tar.gz: 87a98fd2e4a92fe29ea889363f13c17e73f783a94160d37d8f3ff5dbbb710980bf281040d09a598654aa5dba1404ab83b1df8d19c7c0703b69d53640387c0e4e
@@ -1,6 +1,32 @@
1
1
  # //= require ace/theme-monokai
2
2
  # //= require ace/mode-ruby
3
3
  # In order to have digested assets function properly, theme and mode must be required up front
4
+ class EditorHeight
5
+ constructor: (scope,element,attributes)->
6
+ @scope = scope
7
+ @element = element
8
+ @attributes = attributes
9
+
10
+ minHeight: ->
11
+ heights = []
12
+ e = @element[0].parentElement.parentElement
13
+ while e
14
+ heights.push(e.offsetHeight) unless e.offsetHeight == 0
15
+ e = e.parentElement
16
+
17
+ height: ->
18
+ return @minHeight() + 'px' unless @attributes.editorSize
19
+ raw_equation = @attributes.editorSize.replace /[\+\-\/\*]/g, (operator)->
20
+ return " " + operator + " "
21
+ equation = []
22
+ for el in raw_equation.split(/\s+/)
23
+ unless el.match(/(^[\d+]?[.]?[\d+]$)|[\+\-\/\*]/)
24
+ method = 'getElement' + if el[0] == "#" then 'ById' else 'sByClass'
25
+ equation.push document[method](el[1..-1]).offsetHeight
26
+ else
27
+ equation.push(el)
28
+ return @scope.$eval(equation.join(' ')) + 'px'
29
+
4
30
  angular.module('materialRaingularAce', [])
5
31
  .directive 'codeEditor', ($timeout, factoryName, $injector)->
6
32
  restrict: 'E'
@@ -9,23 +35,24 @@ angular.module('materialRaingularAce', [])
9
35
  template: (element,attributes) ->
10
36
  websocketHelper = ->
11
37
  if typeof attributes.webSocket == 'undefined' then 'update' else 'model'
12
- '<span><div id="process-code-editor"></div><input type="hidden" ng-' + websocketHelper + '="' + attributes.ngModel + '"</span>'
38
+ id = attributes['editorId'] || attributes.ngModel.replace('.','-') + "-code-editor"
39
+ '<span><div id="' + id + '"></div><input type="hidden" ng-' + websocketHelper + '="' + attributes.ngModel + '"</span>'
13
40
  link: (scope, element, attributes, modelCtrl)->
14
- editor = ace.edit("process-code-editor")
41
+ id = attributes['editorId'] || attributes.ngModel.replace('.','-') + "-code-editor"
42
+ angular.ace = {} unless angular.ace
43
+ editor = ace.edit(id)
15
44
  editor.setTheme("ace/theme/monokai")
16
45
  editor.getSession().setMode("ace/mode/ruby")
17
46
  editor.getSession().setTabSize(2)
18
47
  editor.getSession().setUseSoftTabs(true)
19
48
  editor.$blockScrolling = Infinity
20
- span = angular.element(document.getElementById('process-code-editor'))
21
- heights = []
22
- e = element[0].parentElement.parentElement
23
- while e
24
- heights.push(e.offsetHeight) unless e.offsetHeight == 0
25
- e = e.parentElement
49
+ angular.ace[id] = editor
50
+ span = angular.element(document.getElementById(id))
51
+ editorHeight = new EditorHeight(scope,element,attributes)
26
52
  angular.element(window).on 'resize', (event)->
27
- span.css('height',heights.min() + 'px')
28
- span.css('fontSize', '14px').css('height',heights.min() + 'px')
53
+ span.css('height',editorHeight.height())
54
+ editor.resize()
55
+ span.css('fontSize', '14px').css('height',editorHeight.height())
29
56
  scope.$watch attributes.ngModel, (newVal, oldVal) ->
30
57
  unless newVal == editor.getValue()
31
58
  if newVal && oldVal
@@ -1,5 +1,5 @@
1
1
  module MaterialRaingular
2
2
  module Ace
3
- VERSION = "0.0.2.alpha"
3
+ VERSION = "0.0.3.alpha"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material_raingular-ace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.alpha
4
+ version: 0.0.3.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moody
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler