youthtree-js 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,18 +12,32 @@ YouthTree JS provides a small number of different pieces of code for a variety o
12
12
 
13
13
  Out of the box, the main namespaces are:
14
14
 
15
- ### YouthTree.CKEditor
15
+ ### YouthTree.Forms.CKEditor
16
16
 
17
17
  A simple wrapper around CKEditor that unobtrusively sets up the jQuery adapter on fields
18
18
  with a class of `.ckeditor` on the container. Also, the width is set to deal with the
19
19
  common [bhm-admin](http://github.com/YouthTree/bhm-admin) sides images.
20
20
 
21
- ### YouthTree.ConvertableEditor
21
+ ### YouthTree.Forms.ConvertableEditor
22
22
 
23
23
  Even more magic for YouthTree.CKEditor. Let's you mark a fieldset wrapper with `.convertable` and it'll
24
24
  automatically find the select and textarea, showing when the select has a format of "raw". Designed
25
25
  to work out of the box with how most [almost-happy](http://github.com/Sutto/almost-happy) editors work.
26
26
 
27
+ ### YouthTree.Forms.ValueCloner
28
+
29
+ Unobtrusive support for a simple way to clone the value between two different fields.
30
+
31
+ Ideally useful for things with a start and end time where you want to make it possible
32
+ to provide a button to clone the value into the second.
33
+
34
+ ### YouthTree.Forms.DatePicker
35
+
36
+ Simple support for http://trentrichardson.com/examples/timepicker/ being unobtrusively
37
+ added to a given form.
38
+
39
+ Also, will hook up jQuery UI datepickers.
40
+
27
41
  ### YouthTree.Disqus
28
42
 
29
43
  Unobtrusively adds the Disqus html based on the presence of meta tags in the page with the names:
data/Rakefile CHANGED
@@ -27,3 +27,4 @@ task :compile_scripts do
27
27
  end
28
28
  end
29
29
 
30
+ task :default => :compile_scripts
@@ -1,4 +1,4 @@
1
- YouthTree.withNS 'CKEditor', (ns) ->
1
+ YouthTree.withNS 'Forms.CKEditor', (ns) ->
2
2
 
3
3
  window.CKEDITOR_BASEPATH = '/ckeditor/'
4
4
 
@@ -1,14 +1,16 @@
1
- YouthTree.withNS 'ConvertableEditor', (ns) ->
1
+ YouthTree.withNS 'Forms.ConvertableEditor', (ns) ->
2
+
3
+ CKEditor = YouthTree.Forms.CKEditor
2
4
 
3
5
  ns.containerSelector = 'fieldset.inputs.convertable'
4
6
  ns.editorSelector = 'textarea'
5
7
  ns.formatSelector = 'select'
6
8
 
7
9
  ns.showEditor = (s) ->
8
- YouthTree.CKEditor.makeEditor s
10
+ CKEditor.makeEditor s
9
11
 
10
12
  ns.hideEditor = (s) ->
11
- YouthTree.CKEditor.destroyEditor s
13
+ CKEditor.destroyEditor s
12
14
 
13
15
  ns.shouldShowEditor = (s) ->
14
16
  s.find(ns.formatSelector).val() is "raw"
@@ -0,0 +1,20 @@
1
+ YouthTree.withNS 'Forms.DatePicker', (ns) ->
2
+
3
+ ns.timeFormat = 'hh:mm TT'
4
+ ns.dateFormat = 'dd MM yy'
5
+
6
+ ns.makeDatePickers = ->
7
+ return unless $.fn.datepicker?
8
+ $('input.ui-date-picker').datepicker dateFormat: ns.dateFormat
9
+
10
+ ns.makeDateTimePickers = ->
11
+ return unless $.fn.datetimepicker?
12
+ $('input.ui-date-picker').datetimepicker
13
+ dateFormat: ns.dateFormat
14
+ timeFormat: ns.timeFormat
15
+ ampm: true
16
+
17
+ ns.setup = ->
18
+ $(document).ready ->
19
+ ns.makeDatePickers()
20
+ ns.makeDateTimePickers()
@@ -0,0 +1,14 @@
1
+ YouthTree.withNS 'Forms.ValueCloner', (ns) ->
2
+
3
+ ns.cloneValue = (from, to) ->
4
+ to.val from.val() if from.length and to.length
5
+
6
+ ns.setup = ->
7
+ $('a.clone-form-value').each ->
8
+ current = $ this
9
+ from_selector = current.dataAttr 'clone-from'
10
+ to_selector = current.dataAttr 'clone-to'
11
+ current.click ->
12
+ if from_selector? and to_selector?
13
+ ns.cloneValue $(from_selector), $(to_selector)
14
+ false
@@ -0,0 +1,27 @@
1
+ YouthTree.withNS('Forms.CKEditor', function(ns) {
2
+ var currentEditorOptions;
3
+ window.CKEDITOR_BASEPATH = '/ckeditor/';
4
+ ns.editorSelector = '.ckeditor textarea';
5
+ ns.editorOptions = {
6
+ toolbar: 'youthtree',
7
+ width: '71%',
8
+ customConfig: false
9
+ };
10
+ ns.toolbar_layout = [['Source', '-', 'Templates'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'SpellChecker', 'Scayt'], ['Undo', 'Redo', '-', 'Find', 'Replace', 'RemoveFormat'], '/', ['Bold', 'Italic', 'Underline', 'Strike'], ['NumberedList', 'BulletedList', 'Blockquote'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink', 'Anchor'], ['Image', 'Flash', 'Table', 'HorizontalRule'], '/', ['Styles', 'Format', 'Font', 'FontSize'], ['TextColor', 'BGColor'], ['Maximize', 'ShowBlocks']];
11
+ currentEditorOptions = function() {
12
+ var options;
13
+ options = $.extend({}, ns.editorOptions);
14
+ options.toolbar_youthtree = ns.toolbar_layout;
15
+ return options;
16
+ };
17
+ ns.makeEditor = function(jq) {
18
+ return jq.ckeditor(currentEditorOptions());
19
+ };
20
+ ns.destroyEditor = function(jq) {
21
+ var _ref, _ref2;
22
+ return (typeof (_ref2 = ((_ref = jq.ckeditorGet()))) === "undefined" || _ref2 === null) ? undefined : _ref2.destroy();
23
+ };
24
+ return (ns.setup = function() {
25
+ return ns.makeEditor($(ns.editorSelector));
26
+ });
27
+ });
@@ -0,0 +1,35 @@
1
+ var __bind = function(func, context) {
2
+ return function(){ return func.apply(context, arguments); };
3
+ };
4
+ YouthTree.withNS('Forms.ConvertableEditor', function(ns) {
5
+ var CKEditor;
6
+ CKEditor = YouthTree.Forms.CKEditor;
7
+ ns.containerSelector = 'fieldset.inputs.convertable';
8
+ ns.editorSelector = 'textarea';
9
+ ns.formatSelector = 'select';
10
+ ns.showEditor = function(s) {
11
+ return CKEditor.makeEditor(s);
12
+ };
13
+ ns.hideEditor = function(s) {
14
+ return CKEditor.destroyEditor(s);
15
+ };
16
+ ns.shouldShowEditor = function(s) {
17
+ return s.find(ns.formatSelector).val() === "raw";
18
+ };
19
+ ns.toggleEditorOn = function(scope) {
20
+ var $scope;
21
+ ns.debug(scope);
22
+ $scope = $(scope);
23
+ return ns.shouldShowEditor($scope) ? ns.showEditor($scope.find(ns.editorSelector)) : ns.hideEditor($scope.find(ns.editorSelector));
24
+ };
25
+ ns.attachEvents = function() {
26
+ return $(ns.containerSelector).each(function() {
27
+ return $(this).find(ns.formatSelector).change(__bind(function() {
28
+ return ns.toggleEditorOn(this);
29
+ }, this));
30
+ });
31
+ };
32
+ return (ns.setup = function() {
33
+ return ns.attachEvents();
34
+ });
35
+ });
@@ -0,0 +1,30 @@
1
+ YouthTree.withNS('Forms.DatePicker', function(ns) {
2
+ ns.timeFormat = 'hh:mm TT';
3
+ ns.dateFormat = 'dd MM yy';
4
+ ns.makeDatePickers = function() {
5
+ var _ref;
6
+ if (!(typeof (_ref = $.fn.datepicker) !== "undefined" && _ref !== null)) {
7
+ return null;
8
+ }
9
+ return $('input.ui-date-picker').datepicker({
10
+ dateFormat: ns.dateFormat
11
+ });
12
+ };
13
+ ns.makeDateTimePickers = function() {
14
+ var _ref;
15
+ if (!(typeof (_ref = $.fn.datetimepicker) !== "undefined" && _ref !== null)) {
16
+ return null;
17
+ }
18
+ return $('input.ui-date-picker').datetimepicker({
19
+ dateFormat: ns.dateFormat,
20
+ timeFormat: ns.timeFormat,
21
+ ampm: true
22
+ });
23
+ };
24
+ return (ns.setup = function() {
25
+ return $(document).ready(function() {
26
+ ns.makeDatePickers();
27
+ return ns.makeDateTimePickers();
28
+ });
29
+ });
30
+ });
@@ -0,0 +1,21 @@
1
+ YouthTree.withNS('Forms.ValueCloner', function(ns) {
2
+ ns.cloneValue = function(from, to) {
3
+ if (from.length && to.length) {
4
+ return to.val(from.val());
5
+ }
6
+ };
7
+ return (ns.setup = function() {
8
+ return $('a.clone-form-value').each(function() {
9
+ var current, from_selector, to_selector;
10
+ current = $(this);
11
+ from_selector = current.dataAttr('clone-from');
12
+ to_selector = current.dataAttr('clone-to');
13
+ return current.click(function() {
14
+ if ((typeof from_selector !== "undefined" && from_selector !== null) && (typeof to_selector !== "undefined" && to_selector !== null)) {
15
+ ns.cloneValue($(from_selector), $(to_selector));
16
+ }
17
+ return false;
18
+ });
19
+ });
20
+ });
21
+ });
data/lib/youthtree-js.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class YouthTreeJS
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
 
4
4
  def self.coffeescripts_root
5
5
  File.expand_path('../coffeescripts', File.dirname(__FILE__))
data/youthtree-js.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{youthtree-js}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Darcy Laycock"]
12
- s.date = %q{2010-11-29}
12
+ s.date = %q{2010-12-02}
13
13
  s.description = %q{Shared Javascript tools across YouthTree apps.}
14
14
  s.email = %q{sutto@sutto.net}
15
15
  s.extra_rdoc_files = [
@@ -19,11 +19,13 @@ Gem::Specification.new do |s|
19
19
  "README.md",
20
20
  "Rakefile",
21
21
  "coffeescripts/youth_tree.coffee",
22
- "coffeescripts/youth_tree/ck_editor.coffee",
23
- "coffeescripts/youth_tree/convertable_editor.coffee",
24
22
  "coffeescripts/youth_tree/disqus.coffee",
25
23
  "coffeescripts/youth_tree/flickr.coffee",
26
24
  "coffeescripts/youth_tree/flickr/gallery.coffee",
25
+ "coffeescripts/youth_tree/forms/ck_editor.coffee",
26
+ "coffeescripts/youth_tree/forms/convertable_editor.coffee",
27
+ "coffeescripts/youth_tree/forms/date_picker.coffee",
28
+ "coffeescripts/youth_tree/forms/value_cloner.coffee",
27
29
  "coffeescripts/youth_tree/gallery.coffee",
28
30
  "coffeescripts/youth_tree/util.coffee",
29
31
  "javascripts/youth_tree.js",
@@ -32,6 +34,10 @@ Gem::Specification.new do |s|
32
34
  "javascripts/youth_tree/disqus.js",
33
35
  "javascripts/youth_tree/flickr.js",
34
36
  "javascripts/youth_tree/flickr/gallery.js",
37
+ "javascripts/youth_tree/forms/ck_editor.js",
38
+ "javascripts/youth_tree/forms/convertable_editor.js",
39
+ "javascripts/youth_tree/forms/date_picker.js",
40
+ "javascripts/youth_tree/forms/value_cloner.js",
35
41
  "javascripts/youth_tree/gallery.js",
36
42
  "javascripts/youth_tree/util.js",
37
43
  "lib/youthtree-js.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youthtree-js
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Darcy Laycock
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-29 00:00:00 +08:00
18
+ date: 2010-12-02 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,11 +31,13 @@ files:
31
31
  - README.md
32
32
  - Rakefile
33
33
  - coffeescripts/youth_tree.coffee
34
- - coffeescripts/youth_tree/ck_editor.coffee
35
- - coffeescripts/youth_tree/convertable_editor.coffee
36
34
  - coffeescripts/youth_tree/disqus.coffee
37
35
  - coffeescripts/youth_tree/flickr.coffee
38
36
  - coffeescripts/youth_tree/flickr/gallery.coffee
37
+ - coffeescripts/youth_tree/forms/ck_editor.coffee
38
+ - coffeescripts/youth_tree/forms/convertable_editor.coffee
39
+ - coffeescripts/youth_tree/forms/date_picker.coffee
40
+ - coffeescripts/youth_tree/forms/value_cloner.coffee
39
41
  - coffeescripts/youth_tree/gallery.coffee
40
42
  - coffeescripts/youth_tree/util.coffee
41
43
  - javascripts/youth_tree.js
@@ -44,6 +46,10 @@ files:
44
46
  - javascripts/youth_tree/disqus.js
45
47
  - javascripts/youth_tree/flickr.js
46
48
  - javascripts/youth_tree/flickr/gallery.js
49
+ - javascripts/youth_tree/forms/ck_editor.js
50
+ - javascripts/youth_tree/forms/convertable_editor.js
51
+ - javascripts/youth_tree/forms/date_picker.js
52
+ - javascripts/youth_tree/forms/value_cloner.js
47
53
  - javascripts/youth_tree/gallery.js
48
54
  - javascripts/youth_tree/util.js
49
55
  - lib/youthtree-js.rb