| |   |
| 1 | | |
| 2 | | require 'gruff' |
| 3 | | |
| 4 | 1 | class ProjectsController < ApplicationController |
| 5 | 2 | before_filter :login_required, :only => [:create, :update, :destroy, :new] |
| 6 | 3 | before_filter :require_user_has_ssh_keys, :only => [:new, :create] |
| … | … | |
| 82 | 82 | end |
| 83 | 83 | redirect_to projects_path |
| 84 | 84 | end |
| 85 | | |
| 86 | | def commit_graph |
| 87 | | @project = Project.find_by_slug!(params[:id]) |
| 88 | | sha = params[:sha] ? params[:sha] : "master" |
| 89 | | |
| 90 | | repo = @project.mainline_repository |
| 91 | | git_repo = repo.git |
| 92 | | git = git_repo.git |
| 93 | | |
| 94 | | width = params[:width] ? params[:width].to_i : 250 |
| 95 | | |
| 96 | | h = Hash.new |
| 97 | | dategroup = Date.new |
| 98 | | |
| 99 | | data = git.rev_list({:pretty => "format:%aD", :since => "24 weeks ago"}, sha) |
| 100 | | data.each_line { |line| |
| 101 | | if line =~ /\d\d:\d\d:\d\d/ then |
| 102 | | date = Date.parse(line) |
| 103 | | |
| 104 | | dategroup = Date.new(date.year, date.month, 1) |
| 105 | | if h[dategroup] |
| 106 | | h[dategroup] += 1 |
| 107 | | else |
| 108 | | h[dategroup] = 1 |
| 109 | | end |
| 110 | | end |
| 111 | | } |
| 112 | | |
| 113 | | g = Gruff::Line.new(width) |
| 114 | | setup_gruff(g) |
| 115 | | g.hide_legend = true |
| 116 | | g.title = "#{@project.title} commits" |
| 117 | | |
| 118 | | commits = [] |
| 119 | | labels = {} |
| 120 | | it = 0 |
| 121 | | h.sort.each { |entry| |
| 122 | | date = entry.first |
| 123 | | value = entry.last |
| 124 | | |
| 125 | | labels[it] = date.strftime("%m/%y") |
| 126 | | commits << value |
| 127 | | it+=1 |
| 128 | | } |
| 129 | | |
| 130 | | unless commits.empty? |
| 131 | | g.data("Commits", commits) |
| 132 | | g.labels = labels |
| 133 | | # g.labels = { 0 => labels.first, commits.size-1 => labels.last } |
| 134 | | end |
| 135 | | |
| 136 | | send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.slug}-commits.png") |
| 137 | | end |
| 138 | | |
| 139 | | def commit_graph_by_author |
| 140 | | @project = Project.find_by_slug!(params[:id]) |
| 141 | | sha = params[:sha] ? params[:sha] : "master" |
| 142 | | |
| 143 | | repo = @project.mainline_repository |
| 144 | | git_repo = repo.git |
| 145 | | git = git_repo.git |
| 146 | | |
| 147 | | width = params[:width] ? params[:width].to_i : 400 |
| 148 | | |
| 149 | | h = Hash.new |
| 150 | | |
| 151 | | data = git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, sha) |
| 152 | | data.each_line { |line| |
| 153 | | if line =~ /^name:(.*)$/ then |
| 154 | | author = $1 |
| 155 | | |
| 156 | | if h[author] |
| 157 | | h[author] += 1 |
| 158 | | else |
| 159 | | h[author] = 1 |
| 160 | | end |
| 161 | | end |
| 162 | | } |
| 163 | | |
| 164 | | g = Gruff::Pie.new(width) |
| 165 | | setup_gruff(g) |
| 166 | | g.title = "#{@project.title}" |
| 167 | | |
| 168 | | sorted = h.sort_by { |author, commits| |
| 169 | | commits |
| 170 | | } |
| 171 | | |
| 172 | | label_it = 0 |
| 173 | | labels = {} |
| 174 | | max = 5 |
| 175 | | others = [] |
| 176 | | top = sorted |
| 177 | | |
| 178 | | if sorted.size > max |
| 179 | | top = sorted[sorted.size-max, sorted.size] |
| 180 | | others = sorted[0, sorted.size-max] |
| 181 | | end |
| 182 | | |
| 183 | | top.each { |entry| |
| 184 | | v = entry.last |
| 185 | | g.data(entry.first, [v]) |
| 186 | | |
| 187 | | labels[label_it] = v |
| 188 | | label_it += 1 |
| 189 | | } |
| 190 | | |
| 191 | | unless others.empty? |
| 192 | | others_v = others.inject { |v, acum| [v.last + acum.last] } |
| 193 | | labels[label_it] = others_v.first |
| 194 | | g.data("others", others_v ) |
| 195 | | end |
| 196 | | |
| 197 | | g.labels = labels |
| 198 | | |
| 199 | | send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.slug}-commits_author.png") |
| 200 | | end |
| 201 | | |
| 202 | | private |
| 203 | | def setup_gruff(g) |
| 204 | | g.no_data_message = "No commits" |
| 205 | | |
| 206 | | colors = [ |
| 207 | | '#a9dada', # blue |
| 208 | | '#aedaa9', # green |
| 209 | | '#dadaa9', # yellow |
| 210 | | '#daaea9', # peach |
| 211 | | '#a9a9da', # dk purple |
| 212 | | '#daaeda', # purple |
| 213 | | '#dadada' # grey |
| 214 | | ] |
| 215 | | |
| 216 | | g.theme = { |
| 217 | | :colors => colors, |
| 218 | | :marker_color => '#aea9a9', # Grey |
| 219 | | :font_color => 'black', |
| 220 | | :background_colors => '#efefef' |
| 221 | | } |
| 222 | | |
| 223 | | g |
| 224 | | end |
| 225 | 85 | end |
| toggle raw diff |
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -1,6 +1,3 @@
-
-require 'gruff'
-
class ProjectsController < ApplicationController
before_filter :login_required, :only => [:create, :update, :destroy, :new]
before_filter :require_user_has_ssh_keys, :only => [:new, :create]
@@ -85,144 +82,4 @@ class ProjectsController < ApplicationController
end
redirect_to projects_path
end
-
- def commit_graph
- @project = Project.find_by_slug!(params[:id])
- sha = params[:sha] ? params[:sha] : "master"
-
- repo = @project.mainline_repository
- git_repo = repo.git
- git = git_repo.git
-
- width = params[:width] ? params[:width].to_i : 250
-
- h = Hash.new
- dategroup = Date.new
-
- data = git.rev_list({:pretty => "format:%aD", :since => "24 weeks ago"}, sha)
- data.each_line { |line|
- if line =~ /\d\d:\d\d:\d\d/ then
- date = Date.parse(line)
-
- dategroup = Date.new(date.year, date.month, 1)
- if h[dategroup]
- h[dategroup] += 1
- else
- h[dategroup] = 1
- end
- end
- }
-
- g = Gruff::Line.new(width)
- setup_gruff(g)
- g.hide_legend = true
- g.title = "#{@project.title} commits"
-
- commits = []
- labels = {}
- it = 0
- h.sort.each { |entry|
- date = entry.first
- value = entry.last
-
- labels[it] = date.strftime("%m/%y")
- commits << value
- it+=1
- }
-
- unless commits.empty?
- g.data("Commits", commits)
- g.labels = labels
-# g.labels = { 0 => labels.first, commits.size-1 => labels.last }
- end
-
- send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.slug}-commits.png")
- end
-
- def commit_graph_by_author
- @project = Project.find_by_slug!(params[:id])
- sha = params[:sha] ? params[:sha] : "master"
-
- repo = @project.mainline_repository
- git_repo = repo.git
- git = git_repo.git
-
- width = params[:width] ? params[:width].to_i : 400
-
- h = Hash.new
-
- data = git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, sha)
- data.each_line { |line|
- if line =~ /^name:(.*)$/ then
- author = $1
-
- if h[author]
- h[author] += 1
- else
- h[author] = 1
- end
- end
- }
-
- g = Gruff::Pie.new(width)
- setup_gruff(g)
- g.title = "#{@project.title}"
-
- sorted = h.sort_by { |author, commits|
- commits
- }
-
- label_it = 0
- labels = {}
- max = 5
- others = []
- top = sorted
-
- if sorted.size > max
- top = sorted[sorted.size-max, sorted.size]
- others = sorted[0, sorted.size-max]
- end
-
- top.each { |entry|
- v = entry.last
- g.data(entry.first, [v])
-
- labels[label_it] = v
- label_it += 1
- }
-
- unless others.empty?
- others_v = others.inject { |v, acum| [v.last + acum.last] }
- labels[label_it] = others_v.first
- g.data("others", others_v )
- end
-
- g.labels = labels
-
- send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.slug}-commits_author.png")
- end
-
- private
- def setup_gruff(g)
- g.no_data_message = "No commits"
-
- colors = [
- '#a9dada', # blue
- '#aedaa9', # green
- '#dadaa9', # yellow
- '#daaea9', # peach
- '#a9a9da', # dk purple
- '#daaeda', # purple
- '#dadada' # grey
- ]
-
- g.theme = {
- :colors => colors,
- :marker_color => '#aea9a9', # Grey
- :font_color => 'black',
- :background_colors => '#efefef'
- }
-
- g
- end
end
\ No newline at end of file |
| |   |
| 73 | 73 | def flashes |
| 74 | 74 | flash.map {|type, content| content_tag(:div, content_tag(:p, content), :class => "flash_message #{type}")} |
| 75 | 75 | end |
| 76 | |
| 77 | def commit_graph_tag(project, sha = "master") |
| 78 | repo = project.mainline_repository |
| 79 | git_repo = repo.git |
| 80 | git = git_repo.git |
| 81 | |
| 82 | h = Hash.new |
| 83 | dategroup = Date.new |
| 84 | |
| 85 | data = git.rev_list({:pretty => "format:%aD", :since => "24 weeks ago"}, sha) |
| 86 | data.each_line { |line| |
| 87 | if line =~ /\d\d:\d\d:\d\d/ then |
| 88 | date = Date.parse(line) |
| 89 | |
| 90 | dategroup = Date.new(date.year, date.month, 1) |
| 91 | if h[dategroup] |
| 92 | h[dategroup] += 1 |
| 93 | else |
| 94 | h[dategroup] = 1 |
| 95 | end |
| 96 | end |
| 97 | } |
| 98 | |
| 99 | commits = [] |
| 100 | labels = [] |
| 101 | h.sort.each { |entry| |
| 102 | date = entry.first |
| 103 | value = entry.last |
| 104 | |
| 105 | labels << date.strftime("%m/%y") |
| 106 | commits << value |
| 107 | } |
| 108 | |
| 109 | Gchart.line(:data => commits, :labels => labels, :bg => "efefef", :format => "img_tag") |
| 110 | end |
| 111 | |
| 112 | def commit_graph_by_author_tag(project, sha = "master") |
| 113 | repo = project.mainline_repository |
| 114 | git_repo = repo.git |
| 115 | git = git_repo.git |
| 116 | |
| 117 | h = Hash.new |
| 118 | |
| 119 | data = git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, sha) |
| 120 | data.each_line { |line| |
| 121 | if line =~ /^name:(.*)$/ then |
| 122 | author = $1 |
| 123 | |
| 124 | if h[author] |
| 125 | h[author] += 1 |
| 126 | else |
| 127 | h[author] = 1 |
| 128 | end |
| 129 | end |
| 130 | } |
| 131 | |
| 132 | sorted = h.sort_by { |author, commits| |
| 133 | commits |
| 134 | } |
| 135 | |
| 136 | labels = [] |
| 137 | data = [] |
| 138 | |
| 139 | max = 5 |
| 140 | others = [] |
| 141 | top = sorted |
| 142 | |
| 143 | |
| 144 | if sorted.size > max |
| 145 | top = sorted[sorted.size-max, sorted.size] |
| 146 | others = sorted[0, sorted.size-max] |
| 147 | end |
| 148 | |
| 149 | top.each { |entry| |
| 150 | author = entry.first |
| 151 | v = entry.last |
| 152 | |
| 153 | data << v |
| 154 | labels << author |
| 155 | } |
| 156 | |
| 157 | unless others.empty? |
| 158 | others_v = others.inject { |v, acum| [v.last + acum.last] } |
| 159 | labels[label_it] = others_v.first |
| 160 | |
| 161 | labels << "others" |
| 162 | data << others_v |
| 163 | end |
| 164 | |
| 165 | Gchart.pie(:data => data, :labels => labels, :width => 400, :bg => "efefef", :format => "img_tag" ) |
| 166 | end |
| 76 | 167 | end |
| toggle raw diff |
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -73,4 +73,95 @@ module ApplicationHelper
def flashes
flash.map {|type, content| content_tag(:div, content_tag(:p, content), :class => "flash_message #{type}")}
end
+
+ def commit_graph_tag(project, sha = "master")
+ repo = project.mainline_repository
+ git_repo = repo.git
+ git = git_repo.git
+
+ h = Hash.new
+ dategroup = Date.new
+
+ data = git.rev_list({:pretty => "format:%aD", :since => "24 weeks ago"}, sha)
+ data.each_line { |line|
+ if line =~ /\d\d:\d\d:\d\d/ then
+ date = Date.parse(line)
+
+ dategroup = Date.new(date.year, date.month, 1)
+ if h[dategroup]
+ h[dategroup] += 1
+ else
+ h[dategroup] = 1
+ end
+ end
+ }
+
+ commits = []
+ labels = []
+ h.sort.each { |entry|
+ date = entry.first
+ value = entry.last
+
+ labels << date.strftime("%m/%y")
+ commits << value
+ }
+
+ Gchart.line(:data => commits, :labels => labels, :bg => "efefef", :format => "img_tag")
+ end
+
+ def commit_graph_by_author_tag(project, sha = "master")
+ repo = project.mainline_repository
+ git_repo = repo.git
+ git = git_repo.git
+
+ h = Hash.new
+
+ data = git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, sha)
+ data.each_line { |line|
+ if line =~ /^name:(.*)$/ then
+ author = $1
+
+ if h[author]
+ h[author] += 1
+ else
+ h[author] = 1
+ end
+ end
+ }
+
+ sorted = h.sort_by { |author, commits|
+ commits
+ }
+
+ labels = []
+ data = []
+
+ max = 5
+ others = []
+ top = sorted
+
+
+ if sorted.size > max
+ top = sorted[sorted.size-max, sorted.size]
+ others = sorted[0, sorted.size-max]
+ end
+
+ top.each { |entry|
+ author = entry.first
+ v = entry.last
+
+ data << v
+ labels << author
+ }
+
+ unless others.empty?
+ others_v = others.inject { |v, acum| [v.last + acum.last] }
+ labels[label_it] = others_v.first
+
+ labels << "others"
+ data << others_v
+ end
+
+ Gchart.pie(:data => data, :labels => labels, :width => 400, :bg => "efefef", :format => "img_tag" )
+ end
end |
| |   |
| 1 | | /* Prototype JavaScript framework, version 1.6.0.1 |
| 2 | | * (c) 2005-2007 Sam Stephenson |
| 1 | /* Prototype JavaScript framework, version 1.6.0.2 |
| 2 | * (c) 2005-2008 Sam Stephenson |
| 3 | 3 | * |
| 4 | 4 | * Prototype is freely distributable under the terms of an MIT-style license. |
| 5 | 5 | * For details, see the Prototype web site: http://www.prototypejs.org/ |
| … | … | |
| 7 | 7 | *--------------------------------------------------------------------------*/ |
| 8 | 8 | |
| 9 | 9 | var Prototype = { |
| 10 | | Version: '1.6.0.1', |
| 10 | Version: '1.6.0.2', |
| 11 | 11 | |
| 12 | 12 | Browser: { |
| 13 | 13 | IE: !!(window.attachEvent && !window.opera), |
| … | … | |
| 110 | 110 | try { |
| 111 | 111 | if (Object.isUndefined(object)) return 'undefined'; |
| 112 | 112 | if (object === null) return 'null'; |
| 113 | | return object.inspect ? object.inspect() : object.toString(); |
| 113 | return object.inspect ? object.inspect() : String(object); |
| 114 | 114 | } catch (e) { |
| 115 | 115 | if (e instanceof RangeError) return '...'; |
| 116 | 116 | throw e; |
| … | … | |
| 171 | 171 | }, |
| 172 | 172 | |
| 173 | 173 | isArray: function(object) { |
| 174 | | return object && object.constructor === Array; |
| 174 | return object != null && typeof object == "object" && |
| 175 | 'splice' in object && 'join' in object; |
| 175 | 176 | }, |
| 176 | 177 | |
| 177 | 178 | isHash: function(object) { |
| … | … | |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | return before + String.interpret(ctx); |
| 582 | | }.bind(this)); |
| 582 | }); |
| 583 | 583 | } |
| 584 | 584 | }); |
| 585 | 585 | Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; |
| … | … | |
| 807 | 807 | function $A(iterable) { |
| 808 | 808 | if (!iterable) return []; |
| 809 | 809 | if (iterable.toArray) return iterable.toArray(); |
| 810 | | var length = iterable.length, results = new Array(length); |
| 810 | var length = iterable.length || 0, results = new Array(length); |
| 811 | 811 | while (length--) results[length] = iterable[length]; |
| 812 | 812 | return results; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | if (Prototype.Browser.WebKit) { |
| 816 | | function $A(iterable) { |
| 816 | $A = function(iterable) { |
| 817 | 817 | if (!iterable) return []; |
| 818 | 818 | if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && |
| 819 | 819 | iterable.toArray) return iterable.toArray(); |
| 820 | | var length = iterable.length, results = new Array(length); |
| 820 | var length = iterable.length || 0, results = new Array(length); |
| 821 | 821 | while (length--) results[length] = iterable[length]; |
| 822 | 822 | return results; |
| 823 | | } |
| 823 | }; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | Array.from = $A; |
| … | … | |
| 1299 | 1299 | |
| 1300 | 1300 | var contentType = response.getHeader('Content-type'); |
| 1301 | 1301 | if (this.options.evalJS == 'force' |
| 1302 | | || (this.options.evalJS && contentType |
| 1302 | || (this.options.evalJS && this.isSameOrigin() && contentType |
| 1303 | 1303 | && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) |
| 1304 | 1304 | this.evalResponse(); |
| 1305 | 1305 | } |
| … | … | |
| 1317 | 1317 | } |
| 1318 | 1318 | }, |
| 1319 | 1319 | |
| 1320 | isSameOrigin: function() { |
| 1321 | var m = this.url.match(/^\s*https?:\/\/[^\/]*/); |
| 1322 | return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ |
| 1323 | protocol: location.protocol, |
| 1324 | domain: document.domain, |
| 1325 | port: location.port ? ':' + location.port : '' |
| 1326 | })); |
| 1327 | }, |
| 1328 | |
| 1320 | 1329 | getHeader: function(name) { |
| 1321 | 1330 | try { |
| 1322 | | return this.transport.getResponseHeader(name); |
| 1331 | return this.transport.getResponseHeader(name) || null; |
| 1323 | 1332 | } catch (e) { return null } |
| 1324 | 1333 | }, |
| 1325 | 1334 | |
| … | … | |
| 1401 | 1401 | if (!json) return null; |
| 1402 | 1402 | json = decodeURIComponent(escape(json)); |
| 1403 | 1403 | try { |
| 1404 | | return json.evalJSON(this.request.options.sanitizeJSON); |
| 1404 | return json.evalJSON(this.request.options.sanitizeJSON || |
| 1405 | !this.request.isSameOrigin()); |
| 1405 | 1406 | } catch (e) { |
| 1406 | 1407 | this.request.dispatchException(e); |
| 1407 | 1408 | } |
| … | … | |
| 1415 | 1415 | this.responseText.blank()) |
| 1416 | 1416 | return null; |
| 1417 | 1417 | try { |
| 1418 | | return this.responseText.evalJSON(options.sanitizeJSON); |
| 1418 | return this.responseText.evalJSON(options.sanitizeJSON || |
| 1419 | !this.request.isSameOrigin()); |
| 1419 | 1420 | } catch (e) { |
| 1420 | 1421 | this.request.dispatchException(e); |
| 1421 | 1422 | } |
| … | … | |
| 1620 | 1620 | Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) |
| 1621 | 1621 | insertions = {bottom:insertions}; |
| 1622 | 1622 | |
| 1623 | | var content, t, range; |
| 1623 | var content, insert, tagName, childNodes; |
| 1624 | 1624 | |
| 1625 | | for (position in insertions) { |
| 1625 | for (var position in insertions) { |
| 1626 | 1626 | content = insertions[position]; |
| 1627 | 1627 | position = position.toLowerCase(); |
| 1628 | | t = Element._insertionTranslations[position]; |
| 1628 | insert = Element._insertionTranslations[position]; |
| 1629 | 1629 | |
| 1630 | 1630 | if (content && content.toElement) content = content.toElement(); |
| 1631 | 1631 | if (Object.isElement(content)) { |
| 1632 | | t.insert(element, content); |
| 1632 | insert(element, content); |
| 1633 | 1633 | continue; |
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | content = Object.toHTML(content); |
| 1637 | 1637 | |
| 1638 | | range = element.ownerDocument.createRange(); |
| 1639 | | t.initializeRange(element, range); |
| 1640 | | t.insert(element, range.createContextualFragment(content.stripScripts())); |
| 1638 | tagName = ((position == 'before' || position == 'after') |
| 1639 | ? element.parentNode : element).tagName.toUpperCase(); |
| 1640 | |
| 1641 | childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); |
| 1642 | |
| 1643 | if (position == 'top' || position == 'after') childNodes.reverse(); |
| 1644 | childNodes.each(insert.curry(element)); |
| 1641 | 1645 | |
| 1642 | 1646 | content.evalScripts.bind(content).defer(); |
| 1643 | 1647 | } |
| … | … | |
| 1686 | 1686 | }, |
| 1687 | 1687 | |
| 1688 | 1688 | descendants: function(element) { |
| 1689 | | return $(element).getElementsBySelector("*"); |
| 1689 | return $(element).select("*"); |
| 1690 | 1690 | }, |
| 1691 | 1691 | |
| 1692 | 1692 | firstDescendant: function(element) { |
| … | … | |
| 1725 | 1725 | element = $(element); |
| 1726 | 1726 | if (arguments.length == 1) return $(element.parentNode); |
| 1727 | 1727 | var ancestors = element.ancestors(); |
| 1728 | | return expression ? Selector.findElement(ancestors, expression, index) : |
| 1729 | | ancestors[index || 0]; |
| 1728 | return Object.isNumber(expression) ? ancestors[expression] : |
| 1729 | Selector.findElement(ancestors, expression, index); |
| 1730 | 1730 | }, |
| 1731 | 1731 | |
| 1732 | 1732 | down: function(element, expression, index) { |
| 1733 | 1733 | element = $(element); |
| 1734 | 1734 | if (arguments.length == 1) return element.firstDescendant(); |
| 1735 | | var descendants = element.descendants(); |
| 1736 | | return expression ? Selector.findElement(descendants, expression, index) : |
| 1737 | | descendants[index || 0]; |
| 1735 | return Object.isNumber(expression) ? element.descendants()[expression] : |
| 1736 | element.select(expression)[index || 0]; |
| 1738 | 1737 | }, |
| 1739 | 1738 | |
| 1740 | 1739 | previous: function(element, expression, index) { |
| 1741 | 1740 | element = $(element); |
| 1742 | 1741 | if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); |
| 1743 | 1742 | var previousSiblings = element.previousSiblings(); |
| 1744 | | return expression ? Selector.findElement(previousSiblings, expression, index) : |
| 1745 | | previousSiblings[index || 0]; |
| 1743 | return Object.isNumber(expression) ? previousSiblings[expression] : |
| 1744 | Selector.findElement(previousSiblings, expression, index); |
| 1746 | 1745 | }, |
| 1747 | 1746 | |
| 1748 | 1747 | next: function(element, expression, index) { |
| 1749 | 1748 | element = $(element); |
| 1750 | 1749 | if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); |
| 1751 | 1750 | var nextSiblings = element.nextSiblings(); |
| 1752 | | return expression ? Selector.findElement(nextSiblings, expression, index) : |
| 1753 | | nextSiblings[index || 0]; |
| 1751 | return Object.isNumber(expression) ? nextSiblings[expression] : |
| 1752 | Selector.findElement(nextSiblings, expression, index); |
| 1754 | 1753 | }, |
| 1755 | 1754 | |
| 1756 | 1755 | select: function() { |
| … | … | |
| 1875 | 1875 | do { ancestor = ancestor.parentNode; } |
| 1876 | 1876 | while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); |
| 1877 | 1877 | } |
| 1878 | | if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex); |
| 1878 | if (nextAncestor && nextAncestor.sourceIndex) |
| 1879 | return (e > a && e < nextAncestor.sourceIndex); |
| 1879 | 1880 | } |
| 1880 | 1881 | |
| 1881 | 1882 | while (element = element.parentNode) |
| … | … | |
| 2020 | 2020 | if (element) { |
| 2021 | 2021 | if (element.tagName == 'BODY') break; |
| 2022 | 2022 | var p = Element.getStyle(element, 'position'); |
| 2023 | | if (p == 'relative' || p == 'absolute') break; |
| 2023 | if (p !== 'static') break; |
| 2024 | 2024 | } |
| 2025 | 2025 | } while (element); |
| 2026 | 2026 | return Element._returnOffset(valueL, valueT); |
| … | … | |
| 2169 | 2169 | } |
| 2170 | 2170 | }; |
| 2171 | 2171 | |
| 2172 | | |
| 2173 | | if (!document.createRange || Prototype.Browser.Opera) { |
| 2174 | | Element.Methods.insert = function(element, insertions) { |
| 2175 | | element = $(element); |
| 2176 | | |
| 2177 | | if (Object.isString(insertions) || Object.isNumber(insertions) || |
| 2178 | | Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) |
| 2179 | | insertions = { bottom: insertions }; |
| 2180 | | |
| 2181 | | |