36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/omni_auth.rb', line 36
def request_phase
form = OmniAuth::Form.new(:title => "Auth-Transis Developer Login", :url => callback_path, :header_info => " <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js\"></script>\n <script src=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js\"></script>\n\n <link href=\"http://wwwendt.de/tech/dynatree/src/skin/ui.dynatree.css\" rel=\"stylesheet\" type=\"text/css\">\n <script src=\"http://wwwendt.de/tech/dynatree/src/jquery.dynatree.js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">\n var updateRawInfoJsonFromTree = function(tree){\n var rawInfo = {organizations: [], features: []};\n organizationNames = [];\n $.each(tree.getSelectedNodes(), function(index, node){\nif(node.data.key.organization_name && organizationNames.indexOf(node.data.key.organization_name) == -1){\n organizationNames.push(node.data.key.organization_name);\n}\nif(node.data.key.feature_name){\n rawInfo.features.push({organization_id: organizationNames.indexOf(node.data.key.organization_name)+1, name: node.data.key.feature_name});\n}\n });\n $.each(organizationNames, function(index, name){\nrawInfo.organizations.push({id: index+1, name: name});\n });\n $('#raw_info_json')[0].value = JSON.stringify(rawInfo);\n }\n $(function(){\n var feature = function(organization_name, feature_name, selected){\nreturn {title: feature_name, key: {organization_name: organization_name, feature_name: feature_name}, select: selected};\n }\n var organization = function(name, selected){\nreturn {title: name, expand: true, key: name, children: [\n feature(name,'admin',selected),\n feature(name,'media_plan_creation',selected),\n feature(name,'media_plan_negotiation',selected),\n feature(name,'media_plan_analysis',selected),\n feature(name,'finance',selected)\n ]\n}\n }\n var organizations = [\norganization('Centro',true),\norganization('TransisTestAgency',false),\norganization('TransisTestPublisher',false),\n ];\n $(\"#raw_info\").dynatree({\ncheckbox: true,\nselectMode: 3,\nchildren: organizations,\nonSelect: function(select, node) {\n updateRawInfoJsonFromTree(node.tree);\n},\nonDblClick: function(node, event) {\n node.toggleSelect();\n},\nonKeydown: function(node, event) {\n if( event.which == 32 ) {\n node.toggleSelect();\n return false;\n }\n},\n });\n updateRawInfoJsonFromTree($('#raw_info').dynatree('getRoot').tree);\n });\n</script>\n HTML\n options.fields.each do |field|\n form.text_field field.to_s.capitalize.gsub(\"_\", \" \"), field.to_s\n end\n form.html \"<input type='hidden' id='raw_info_json' name='raw_info_json' />\"\n form.html \"<h3>Features</h3>\"\n form.html \"<div id='raw_info'></div>\"\n form.button \"Sign In\"\n form.to_response\nend\n")
|