simditor-rails 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eec047eb279afe4a2ce42ef44da6fa8a2af4e540
4
+ data.tar.gz: 38515fd63b6f80ce7da112da72b2cb6111a59e7a
5
+ SHA512:
6
+ metadata.gz: 9258bcda4fa23e45c6638a1687fc2c86e5a3aeee73e18d1a545baf06a18e1f98704c1bab19fb1fae020db22642ee35a978384de8cea218a6a9073aae364974a4
7
+ data.tar.gz: 7dfe5455ebbfa5e475ac64926ca187d3418818abe35d67db7b90a037095b5d346360bd12320f1289d836a52a2bdaa520b50f81f4b9ceb4c662242087ac2eb202
@@ -0,0 +1,5 @@
1
+ module Simditor
2
+ module Rails
3
+ VERSION = "1.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "simditor-rails/version"
2
+
3
+ module Simditor
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,80 @@
1
+ class Module
2
+
3
+ @extend: (obj) ->
4
+ return unless obj? and typeof obj is 'object'
5
+ for key, val of obj when key not in ['included', 'extended']
6
+ @[key] = val
7
+ obj.extended?.call(@)
8
+
9
+ @include: (obj) ->
10
+ return unless obj? and typeof obj is 'object'
11
+ for key, val of obj when key not in ['included', 'extended']
12
+ @::[key] = val
13
+ obj.included?.call(@)
14
+
15
+ on: (args...) ->
16
+ $(@).on args...
17
+
18
+ one: (args...) ->
19
+ $(@).one args...
20
+
21
+ off: (args...) ->
22
+ $(@).off args...
23
+
24
+ trigger: (args...) ->
25
+ $(@).trigger args...
26
+
27
+ triggerHandler: (args...) ->
28
+ $(@).triggerHandler args...
29
+
30
+
31
+ class Widget extends Module
32
+
33
+ @connect: (cls) ->
34
+ return unless typeof cls is 'function'
35
+
36
+ unless cls.className
37
+ throw new Error 'Widget.connect: lack of class property "className"'
38
+ return
39
+
40
+ @_connectedClasses = [] unless @_connectedClasses
41
+ @_connectedClasses.push(cls)
42
+ @[cls.className] = cls if cls.className
43
+
44
+ _init: ->
45
+
46
+ opts: {}
47
+
48
+ constructor: (opts) ->
49
+ @opts = $.extend({}, @opts, opts)
50
+
51
+ @constructor._connectedClasses ||= []
52
+
53
+ instances = for cls in @constructor._connectedClasses
54
+ name = cls.className.charAt(0).toLowerCase() + cls.className.slice(1)
55
+ @[name] = new cls(@)
56
+
57
+ @_init()
58
+
59
+ instance._init?() for instance in instances
60
+
61
+ @trigger 'pluginconnected'
62
+
63
+ destroy: ->
64
+
65
+
66
+ class Plugin extends Module
67
+
68
+ @className: 'Plugin'
69
+
70
+ opts: {}
71
+
72
+ constructor: (@widget) ->
73
+ @opts = $.extend({}, @opts, @widget.opts)
74
+
75
+ _init: ->
76
+
77
+
78
+ window.Module = Module
79
+ window.Widget = Widget
80
+ window.Plugin = Plugin