polyblock 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polyblock/polyblock.js.coffee +29 -18
- data/app/views/polyblock/_editor_bar.html.erb +2 -2
- data/lib/polyblock/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +16290 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1926295578648cdc013840b112b4549a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/54e6936a11d8f5cdf5fa2f48475d2207 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/65a5689d2de3f83bcc1531b0bd7918ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/80a9daa2db75d17e5e24d7442ccb41bc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/98c83dce67cf84818203c6f995f4ba36 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f1087ef68b351492e06aa6cfd82d0438 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3071b0b4fbcb4cbda758658ce2e1cbedd4dea609
|
4
|
+
data.tar.gz: 588004b16ffdac1d54ff674dc787d4888cfb2074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11536f64f9533d77f48102547ad5a7686d8cc03f3b6e4d7a048e40d99cd756b132938ff6fd0029562b31a2465188e89e13699816ea13eb2269c85e3964061bfd
|
7
|
+
data.tar.gz: 3e39a8fe52c0ee177ea9ef13270706c6c5edba44aa6513b0e7fa8b954d3eaec3c35d2708600c60d714f7ade4f21f29a3f077ccf32a92837f07ac981be86e790b
|
@@ -1,11 +1,12 @@
|
|
1
1
|
CKEDITOR.disableAutoInline = true;
|
2
|
-
unsavedChanges = false
|
3
|
-
window.onbeforeunload = -> return "Are you sure you want to leave this page? Your unsaved changes will not be stored!" if unsavedChanges
|
4
2
|
|
5
3
|
$ ->
|
4
|
+
$.unsavedChanges = false
|
5
|
+
window.onbeforeunload = ->
|
6
|
+
return "Are you sure you want to leave this page? Your unsaved changes will not be stored!" if $.unsavedChanges
|
6
7
|
$(document).ready ->
|
7
8
|
# Find blocks
|
8
|
-
fetch_blocks =
|
9
|
+
fetch_blocks = => $(".polyblock[contenteditable='true']").not('.polyblock-condensed')
|
9
10
|
blocks = fetch_blocks()
|
10
11
|
return unless blocks.length
|
11
12
|
|
@@ -19,11 +20,14 @@ $ ->
|
|
19
20
|
instanciateCKEditor = (id)->
|
20
21
|
editor = CKEDITOR.inline id,
|
21
22
|
on:
|
22
|
-
contentDom:
|
23
|
-
editor.document.on 'keydown', (e)
|
23
|
+
contentDom: =>
|
24
|
+
editor.document.on 'keydown', (e)=>
|
24
25
|
if (e.data.$.ctrlKey or e.data.$.metaKey) and e.data.$.keyCode == 83
|
25
26
|
try e.data.$.preventDefault()
|
26
|
-
|
27
|
+
# console.log "Before: " + $.unsavedChanges
|
28
|
+
saveChanges =>
|
29
|
+
$.unsavedChanges = false
|
30
|
+
# console.log "After: " + $.unsavedChanges
|
27
31
|
false
|
28
32
|
focus: (e)->
|
29
33
|
editorModeOn()
|
@@ -32,7 +36,7 @@ $ ->
|
|
32
36
|
blocks.each ->
|
33
37
|
id = $(@).attr('id')
|
34
38
|
blockclones[id] = $(@).clone()
|
35
|
-
instanciateCKEditor(id) unless _.contains(_.keys(CKEDITOR.instances),id)
|
39
|
+
instanciateCKEditor(id) unless _.contains(_.keys(CKEDITOR.instances), id)
|
36
40
|
|
37
41
|
# Wait for changes
|
38
42
|
verbose = false
|
@@ -46,23 +50,27 @@ $ ->
|
|
46
50
|
changeChecker = setInterval ->
|
47
51
|
console.log("Checking for changes...") if verbose
|
48
52
|
reading = CKEDITOR.instances[which].getData()
|
49
|
-
if reading!=buffer and
|
50
|
-
else if reading==buffer and unsavedChanges then showSavedChanges()
|
51
|
-
#buffer = reading
|
53
|
+
if reading!=buffer and !$.unsavedChanges then showUnsavedChanges()
|
54
|
+
else if reading==buffer and $.unsavedChanges then showSavedChanges()
|
52
55
|
, 1000
|
53
56
|
stopListening = ->
|
54
57
|
return unless changeChecker?
|
55
58
|
console.log("I'm no longer listening.") if verbose
|
56
59
|
clearInterval(changeChecker)
|
57
60
|
changeChecker = null
|
58
|
-
showUnsavedChanges =
|
61
|
+
showUnsavedChanges = =>
|
59
62
|
indicator.transition({rotate:"-30deg",color:"red"})
|
60
63
|
changeText.html("You have unsaved changes.").transition({color:"red"})
|
61
|
-
unsavedChanges = true
|
64
|
+
$.unsavedChanges = true
|
62
65
|
showSavedChanges = ->
|
63
66
|
indicator.transition({rotate:"0deg",color:"green"})
|
64
67
|
changeText.html("All changes saved.").transition({color:"green"})
|
65
|
-
|
68
|
+
# console.log "In function: " + $.unsavedChanges
|
69
|
+
$.unsavedChanges = false
|
70
|
+
# console.log "In function: " + $.unsavedChanges
|
71
|
+
showSavingChanges = =>
|
72
|
+
indicator.transition({rotate:"30deg",color:"yellow"})
|
73
|
+
changeText.html("Saving changes...").transition({color:"yellow"})
|
66
74
|
|
67
75
|
# Editor functionality toggles
|
68
76
|
initialBodyPadding = $('body').css("padding-bottom")
|
@@ -76,21 +84,24 @@ $ ->
|
|
76
84
|
pb?()
|
77
85
|
|
78
86
|
# Change storage
|
79
|
-
saveChanges = ->
|
80
|
-
|
81
|
-
# pbs = _.object(_.map(blocks,(b)-> $(b).data("pbid")), _.map(blocks,(b)-> $(b).html()))
|
87
|
+
saveChanges = (cb)->
|
88
|
+
showSavingChanges()
|
82
89
|
pbs = _.map blocks, (b)->
|
83
90
|
{
|
84
91
|
id: $(b).attr("data-pbid"),
|
85
92
|
name: $(b).attr("data-pbname"),
|
86
93
|
content: $(b).html()
|
87
94
|
}
|
88
|
-
$.post "/polyblock/update", {pbs: pbs}, (data)->
|
95
|
+
$.post "/polyblock/update", {pbs: pbs}, (data)->
|
96
|
+
showSavedChanges()
|
97
|
+
editorModeOff ->
|
98
|
+
alertify.success("Your changes have been saved.") if alertify?
|
99
|
+
cb?()
|
89
100
|
revertChanges = (pb)->
|
90
101
|
return unless confirm("Are you sure you want to discard your changes?")
|
91
102
|
editorModeOff ->
|
92
103
|
blocks.each -> $(@).replaceWith(blockclones[$(@).attr("id")])
|
93
|
-
alertify.success("Your changes have been discarded.")
|
104
|
+
alertify.success("Your changes have been discarded.") if alertify?
|
94
105
|
|
95
106
|
# Modes
|
96
107
|
currentMode = previousMode = "WYSIWYG"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="navbar navbar-inverse navbar-fixed-bottom" id="pb_bar" role="navigation" style="display:none;">
|
2
2
|
<div class="navbar-header">
|
3
3
|
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".pbbar-collapse">
|
4
|
-
<span class="sr-only">
|
4
|
+
<span class="sr-only">Enable Polyblock Editor</span>
|
5
5
|
<span class="icon-bar"></span>
|
6
6
|
<span class="icon-bar"></span>
|
7
7
|
<span class="icon-bar"></span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<div class="collapse navbar-collapse pbbar-collapse">
|
11
11
|
<span class="navbar-brand" style="margin:6px 0px;">
|
12
12
|
<i class="icon-pencil pb-change-indicator" style="margin-right:6px;"></i>
|
13
|
-
<span class="pb-change-text">
|
13
|
+
<span class="pb-change-text">Polyblock Editor</span>
|
14
14
|
</span>
|
15
15
|
<div class="btn-group" id="pb_bar_format_buttons" style="padding-top:8px;">
|
16
16
|
<button class="btn btn-default btn-navbar active" type="button">WYSIWYG</button>
|
data/lib/polyblock/version.rb
CHANGED
Binary file
|