Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
forrest committed Nov 24, 2011
0 parents commit 5c2b631
Show file tree
Hide file tree
Showing 67 changed files with 1,109 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
20 changes: 20 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
source "http://rubygems.org"

# Declare your gem's dependencies in recurring_select.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
gem "jquery-rails"
gem "pg"
gem "pry"
gem "ice_cube"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
133 changes: 133 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
PATH
remote: .
specs:
recurring_select (0.0.1)
coffee-rails (~> 3.1.1)
ice_cube (~> 0.6)
jquery-rails
rails (~> 3.1.3)
sass-rails (~> 3.1.5)

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
arel (2.2.1)
builder (3.0.0)
coderay (0.9.8)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.2)
erubis (2.7.0)
execjs (1.2.9)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
ice_cube (0.6.14)
jquery-rails (1.0.18)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.6.7)
ruby_parser (>= 2.3.1)
mime-types (1.17.2)
multi_json (1.0.3)
pg (0.11.0)
polyglot (0.3.3)
pry (0.9.7.3)
coderay (~> 0.9.8)
method_source (~> 0.6.7)
ruby_parser (>= 2.3.1)
slop (~> 2.1.0)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
bundler (~> 1.0)
railties (= 3.1.3)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
sass (3.1.10)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sexp_processor (3.0.7)
slop (2.1.0)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)

PLATFORMS
ruby

DEPENDENCIES
ice_cube
jquery-rails
pg
pry
recurring_select!
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2011 YOURNAME

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= RecurringSelect

This project rocks and uses MIT-LICENSE.
39 changes: 39 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'RecurringSelect'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'


Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task :default => :test
Empty file.
Binary file added app/assets/images/recurring_select/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions app/assets/javascripts/recurring_select.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//= require recurring_select_dialog
//= require_self

$ = jQuery
$ ->
$(".recurring_select").each ->
$(this).recurring_select("set_initial_values")

$(document).on "change", ".recurring_select", ->
$(this).recurring_select('changed')

methods =
set_initial_values: ->
@data 'initial-value-hash', @val()
@data 'initial-value-str', $(@find("option").get()[@.prop("selectedIndex")]).text()

changed: ->
if @val() == "custom"
methods.open_custom.apply(@)
else
methods.set_initial_values.apply(@)

open_custom: ->
@data "recurring-select-active", true
new RecurringSelectDialog(@)

set_change: ->
alert "setting changes"

current_rule: ->
str: @data("initial-value-str")
hash: $.parseJSON(@data("initial-value-hash"))

cancel: ->
@val @data("initial-value-hash")
@data "recurring-select-active", false


$.fn.recurring_select = (method) ->
if method of methods
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
else
$.error( "Method #{method} does not exist on jQuery.recurring_select" );
89 changes: 89 additions & 0 deletions app/assets/javascripts/recurring_select_dialog.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
window.RecurringSelectDialog =
class RecurringSelectDialog
constructor: (@recurring_selector) ->
@current_rule = @recurring_selector.recurring_select('current_rule')
@initOuterDialogBox()


initOuterDialogBox: ->
$(".rs_dialog_holder").remove()
@outer_holder = $(document.createElement("div"))
@outer_holder.addClass "rs_dialog_holder"
@inner_holder = $(document.createElement("div"))
@inner_holder.addClass "rs_dialog"
@content = $(document.createElement("div"))
@content.addClass "rs_dialog_content"

@outer_holder.append @inner_holder
@inner_holder.append @content

title = @content.append("<h1>Repeat <a href='#' title='Cancel' Alt='Cancel'></a> </h1>")
cancel_link = title.find('a')

cancel_link.on 'click', @cancel
@outer_holder.on 'click', @cancel
@inner_holder.on 'click', (event) -> event.stopPropagation()

$('body').append @outer_holder
@positionDialog(true)
@setupForm()


positionDialog: (initial_positioning) ->
window_height = $(window).height()
dialog_height = @content.height()
if dialog_height < 100
dialog_height = 100
marginTop = (window_height - dialog_height)/2 - 20

new_style_hash = {"margin-top": marginTop+"px", "height":dialog_height+"px"}
if initial_positioning?
@inner_holder.css new_style_hash
else
@inner_holder.animate new_style_hash

setupForm: ->
@frequencyMethods.addTo.apply @
@summmary.addTo.apply @

cancel: =>
@outer_holder.remove()
@recurring_selector.recurring_select('cancel')

frequencyMethods:
addTo: ->
freq_holder = $(document.createElement("p"))
label = $(document.createElement("label")).text("Frequency")
label.for = "rs_frequency"
@freq_select = $(document.createElement("select"))
@freq_select.name = "rs_frequency"
@freq_select.append $(document.createElement("option")).text("Daily")
@freq_select.append $(document.createElement("option")).text("Weekly")
@freq_select.append $(document.createElement("option")).text("Monthly")
@freq_select.append $(document.createElement("option")).text("Yearly")

freq_holder.append label
freq_holder.append @freq_select
@content.append freq_holder
@frequencyMethods.selectDefault.apply @

selectDefault: ->
rule_type = @current_rule.hash.rule_type
if rule_type?
if rule_type.search(/Weekly/) != -1
@freq_select.prop('selectedIndex', 1)
else if rule_type.search(/Monthly/) != -1
@freq_select.prop('selectedIndex', 2)
else if rule_type.search(/Yearly/) != -1
@freq_select.prop('selectedIndex', 3)

summmary:
addTo: ->
@summary = $(document.createElement("p"))
@summary.addClass "rs_summary"

if @current_rule.str?
@summary.text @current_rule.str

@content.append @summary

Loading

0 comments on commit 5c2b631

Please sign in to comment.