polyblock 0.3.7 → 0.3.9

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: edd641d3a2ddf600f2cd7daf8f1df3a114011d02
4
- data.tar.gz: 8dc664c26f64774d7fd5e43d903593f1ad7da709
3
+ metadata.gz: a144f379db0baf032b3ebfee8bd6d9e1efaa3aed
4
+ data.tar.gz: afd53bafd7a88b3151c9f14bd8f748e5c703a378
5
5
  SHA512:
6
- metadata.gz: a100c4b0ae6c3164196dad65321b7db6531cf022631a35e8ab71ca38ac252b7f983517b4af791add2926365776bda1dd5c217255a8c1294e76c6af4aaa608825
7
- data.tar.gz: c3d828b9025c876b5e2781ef8ac00cfb9a0ccc083c4696c33ef5d95eeb1e41e3dc7a7541fc1c65787ed57f43138105ca782db5313ab6c5c1189b9481117f1f5d
6
+ metadata.gz: 4aa9a039fe6a700224a7b956618881a880585bcd61ab7b2744140519972381f2759d848d7461c41cc909fff82a55c7ddd9cf2133f8d31c41987e322bd1231eb5
7
+ data.tar.gz: 6f55bf7c4cf47a27611d6342d5c00774d4e7a9677d21370f3566b0b3960d75dc6ec3fb889c0f84d532e2442114a60dc2dfb4a4925b207ccfdb9733672cfae407
@@ -17,12 +17,18 @@ $ ->
17
17
  # Clone each block and instanciate CKeditor on the original
18
18
  blockclones = {}
19
19
  instanciateCKEditor = (id)->
20
- CKEDITOR.inline id,
20
+ editor = CKEDITOR.inline id,
21
21
  on:
22
- focus:(e)->
22
+ contentDom: ->
23
+ editor.document.on 'keydown', (e)->
24
+ if (e.data.$.ctrlKey or e.data.$.metaKey) and e.data.$.keyCode == 83
25
+ try e.data.$.preventDefault()
26
+ saveChanges()
27
+ false
28
+ focus: (e)->
23
29
  editorModeOn()
24
30
  startListening(id)
25
- blur:(e)-> stopListening()
31
+ blur: (e)-> stopListening()
26
32
  blocks.each ->
27
33
  id = $(@).attr('id')
28
34
  blockclones[id] = $(@).clone()
@@ -10,6 +10,7 @@ module Polyblock
10
10
  pb_attrs[:id] = attrs[:id] if attrs.has_key?(:id) and !attrs[:id].blank?
11
11
  pb_attrs[:name] = attrs[:name] if attrs.has_key?(:name) and !attrs[:name].blank?
12
12
  pb = Block.find_or_initialize_by pb_attrs
13
+ pb.id = nil if Block.find(pb_attrs[:id]).present? and pb.new_record?
13
14
  pb.content = attrs[:content]
14
15
  pb.save!
15
16
  end
@@ -3,6 +3,7 @@ module Polyblock
3
3
 
4
4
  def pb(name, options={})
5
5
  options = {
6
+ :editable => false,
6
7
  :tag => :div,
7
8
  :tag_options => {},
8
9
  :condensed => false,
@@ -20,12 +21,10 @@ module Polyblock
20
21
  matches = Polyblock::Block.where :name => name
21
22
  pb_exists = matches.any?
22
23
  pb = pb_exists ? matches.first : Polyblock::Block.new({:name => name})
23
- if pb_exists
24
- pb_id = pb.id
24
+ pb_id = if pb_exists
25
+ pb.id
25
26
  else
26
- nextId = Polyblock::Block.count + 1
27
- nextId += 1 while Polyblock::Block.where(:id => nextId).any?
28
- pb_id = nextId
27
+ Polyblock::Block.any? ? Polyblock::Block.order(:id).last.id + 1 : 1
29
28
  end
30
29
  end
31
30
 
@@ -38,6 +37,8 @@ module Polyblock
38
37
  tag_options = options[:tag_options].deep_merge({:id => "pb-#{pb_id}-#{random_id}", :data => {:pbid => pb_id, :pbname => name}})
39
38
  tag_options[:contenteditable] = if options[:condensed]
40
39
  "false"
40
+ elsif options[:editable]
41
+ "true"
41
42
  elsif respond_to?(:can?) && can?(:manage, pb)
42
43
  "true"
43
44
  elsif respond_to?(:user_signed_in?) && user_signed_in?
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  %h1 Polyblock Test Dummy
2
2
 
3
3
  %h3 Polyblock with Inline Editing
4
- = pb("Test")
4
+ = pb "Test", :editable => true
5
5
 
6
6
  %h3 New Polyblock
7
7
  = pb "New"
Binary file