├── js
├── .DS_Store
├── jquery
│ ├── component.json
│ └── composer.json
└── jquery.hotkeys
│ ├── component.json
│ ├── composer.json
│ └── jquery.hotkeys.js
├── icons
├── icon128.png
├── icon16.png
├── icon19.png
├── icon256.png
├── icon48.png
├── icon512.png
├── icon.graffle
└── icon.svg
├── images
├── actionshot.gif
├── promo-small.png
├── screenshot.png
├── promo-small@2x.png
├── promo-small.graffle
│ ├── data.plist
│ └── image2.png
└── screenshot.graffle
│ ├── data.plist
│ └── image5.png
├── tests
├── lib
│ ├── jasmine-2.3.4
│ │ ├── jasmine_favicon.png
│ │ ├── boot.js
│ │ ├── console.js
│ │ ├── jasmine-html.js
│ │ └── jasmine.css
│ ├── mock.js
│ └── jasmine-jquery.js
├── test1.html
├── SpecRunner.html
├── spec
│ └── spec.js
├── test3.html
├── test2.html
├── test8.html
├── test9.html
├── test6.html
├── test5.html
└── test7.html
├── .gitignore
├── src
├── bg
│ ├── background.html
│ └── background.js
├── shared
│ └── shared.js
├── inject
│ ├── inject.css
│ └── inject.js
└── options
│ ├── index.html
│ ├── options.js
│ └── options.css
├── LICENSE
├── manifest.json
└── README.md
/js/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/js/.DS_Store
--------------------------------------------------------------------------------
/icons/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon128.png
--------------------------------------------------------------------------------
/icons/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon16.png
--------------------------------------------------------------------------------
/icons/icon19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon19.png
--------------------------------------------------------------------------------
/icons/icon256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon256.png
--------------------------------------------------------------------------------
/icons/icon48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon48.png
--------------------------------------------------------------------------------
/icons/icon512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon512.png
--------------------------------------------------------------------------------
/icons/icon.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/icons/icon.graffle
--------------------------------------------------------------------------------
/images/actionshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/actionshot.gif
--------------------------------------------------------------------------------
/images/promo-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/promo-small.png
--------------------------------------------------------------------------------
/images/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/screenshot.png
--------------------------------------------------------------------------------
/images/promo-small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/promo-small@2x.png
--------------------------------------------------------------------------------
/images/promo-small.graffle/data.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/promo-small.graffle/data.plist
--------------------------------------------------------------------------------
/images/promo-small.graffle/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/promo-small.graffle/image2.png
--------------------------------------------------------------------------------
/images/screenshot.graffle/data.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/screenshot.graffle/data.plist
--------------------------------------------------------------------------------
/images/screenshot.graffle/image5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/images/screenshot.graffle/image5.png
--------------------------------------------------------------------------------
/tests/lib/jasmine-2.3.4/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jamesandres/ColumnCopy/HEAD/tests/lib/jasmine-2.3.4/jasmine_favicon.png
--------------------------------------------------------------------------------
/tests/lib/mock.js:
--------------------------------------------------------------------------------
1 | chrome = {
2 | extension: {
3 | sendRequest: function(params, callback) {
4 | var options = {};
5 | return options;
6 | }
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Keep junk OUT
2 | *.sql
3 | *.sql.gz
4 | *.sql.bz2
5 | *.kpf
6 | *.komodoproject
7 | *.proj
8 | *.tmp
9 | .DS_Store
10 | Icon
11 | Thumbs.db
12 | .bundle
13 | .sass-cache
14 | *.sublime-project
15 | *.sublime-workspace
16 | ._*
--------------------------------------------------------------------------------
/js/jquery/component.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "version": "3.1.1",
4 | "main": "./jquery.js",
5 | "dependencies": {},
6 | "gitHead": "ee2e377494a882f043e6d8abc67ac6370ee83d9c",
7 | "_id": "jquery@3.1.1",
8 | "readme": "ERROR: No README.md file found!",
9 | "description": "ERROR: No README.md file found!",
10 | "repository": {
11 | "type": "git",
12 | "url": "git@github.com:jquery/jquery.git"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/bg/background.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 | ')
98 | .attr('id', this.containerId)
99 | .html(html)
100 |
101 | $(document.body).append(container)
102 | return container
103 | }
104 |
105 | jasmine.Fixtures.prototype.addToContainer_ = function (html){
106 | var container = $(document.body).find('#'+this.containerId).append(html)
107 |
108 | if (!container.length) {
109 | this.createContainer_(html)
110 | }
111 | }
112 |
113 | jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) {
114 | if (typeof this.fixturesCache_[url] === 'undefined') {
115 | this.loadFixtureIntoCache_(url)
116 | }
117 | return this.fixturesCache_[url]
118 | }
119 |
120 | jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
121 | var self = this
122 | , url = this.makeFixtureUrl_(relativeUrl)
123 | , htmlText = ''
124 | , request = $.ajax({
125 | async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
126 | cache: false,
127 | url: url,
128 | dataType: 'html',
129 | success: function (data, status, $xhr) {
130 | htmlText = $xhr.responseText
131 | }
132 | }).fail(function ($xhr, status, err) {
133 | throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
134 | })
135 |
136 | var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || [];
137 |
138 | scripts.each(function(){
139 | $.ajax({
140 | async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
141 | cache: false,
142 | dataType: 'script',
143 | url: $(this).attr('src'),
144 | success: function (data, status, $xhr) {
145 | htmlText += ''
146 | },
147 | error: function ($xhr, status, err) {
148 | throw new Error('Script could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
149 | }
150 | });
151 | })
152 |
153 | self.fixturesCache_[relativeUrl] = htmlText;
154 | }
155 |
156 | jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
157 | return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
158 | }
159 |
160 | jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
161 | return this[methodName].apply(this, passedArguments)
162 | }
163 |
164 |
165 | jasmine.StyleFixtures = function () {
166 | this.fixturesCache_ = {}
167 | this.fixturesNodes_ = []
168 | this.fixturesPath = 'spec/javascripts/fixtures'
169 | }
170 |
171 | jasmine.StyleFixtures.prototype.set = function (css) {
172 | this.cleanUp()
173 | this.createStyle_(css)
174 | }
175 |
176 | jasmine.StyleFixtures.prototype.appendSet = function (css) {
177 | this.createStyle_(css)
178 | }
179 |
180 | jasmine.StyleFixtures.prototype.preload = function () {
181 | this.read_.apply(this, arguments)
182 | }
183 |
184 | jasmine.StyleFixtures.prototype.load = function () {
185 | this.cleanUp()
186 | this.createStyle_(this.read_.apply(this, arguments))
187 | }
188 |
189 | jasmine.StyleFixtures.prototype.appendLoad = function () {
190 | this.createStyle_(this.read_.apply(this, arguments))
191 | }
192 |
193 | jasmine.StyleFixtures.prototype.cleanUp = function () {
194 | while(this.fixturesNodes_.length) {
195 | this.fixturesNodes_.pop().remove()
196 | }
197 | }
198 |
199 | jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
200 | var styleText = $('
').html(html).text()
201 | , style = $('')
202 |
203 | this.fixturesNodes_.push(style)
204 | $('head').append(style)
205 | }
206 |
207 | jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
208 | jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
209 | jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
210 | jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
211 | jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
212 | jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
213 |
214 | jasmine.getJSONFixtures = function () {
215 | return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
216 | }
217 |
218 | jasmine.JSONFixtures = function () {
219 | this.fixturesCache_ = {}
220 | this.fixturesPath = 'spec/javascripts/fixtures/json'
221 | }
222 |
223 | jasmine.JSONFixtures.prototype.load = function () {
224 | this.read.apply(this, arguments)
225 | return this.fixturesCache_
226 | }
227 |
228 | jasmine.JSONFixtures.prototype.read = function () {
229 | var fixtureUrls = arguments
230 |
231 | for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
232 | this.getFixtureData_(fixtureUrls[urlIndex])
233 | }
234 |
235 | return this.fixturesCache_
236 | }
237 |
238 | jasmine.JSONFixtures.prototype.clearCache = function () {
239 | this.fixturesCache_ = {}
240 | }
241 |
242 | jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
243 | if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
244 | return this.fixturesCache_[url]
245 | }
246 |
247 | jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
248 | var self = this
249 | , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
250 |
251 | $.ajax({
252 | async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
253 | cache: false,
254 | dataType: 'json',
255 | url: url,
256 | success: function (data) {
257 | self.fixturesCache_[relativeUrl] = data
258 | },
259 | error: function ($xhr, status, err) {
260 | throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
261 | }
262 | })
263 | }
264 |
265 | jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
266 | return this[methodName].apply(this, passedArguments)
267 | }
268 |
269 | jasmine.jQuery = function () {}
270 |
271 | jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
272 | return $('
').append(html).html()
273 | }
274 |
275 | jasmine.jQuery.elementToString = function (element) {
276 | return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
277 | }
278 |
279 | var data = {
280 | spiedEvents: {}
281 | , handlers: []
282 | }
283 |
284 | jasmine.jQuery.events = {
285 | spyOn: function (selector, eventName) {
286 | var handler = function (e) {
287 | var calls = (typeof data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] !== 'undefined') ? data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0
288 | data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = {
289 | args: jasmine.util.argsToArray(arguments),
290 | calls: ++calls
291 | }
292 | }
293 |
294 | $(selector).on(eventName, handler)
295 | data.handlers.push(handler)
296 |
297 | return {
298 | selector: selector,
299 | eventName: eventName,
300 | handler: handler,
301 | reset: function (){
302 | delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
303 | },
304 | calls: {
305 | count: function () {
306 | return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
307 | data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0;
308 | },
309 | any: function () {
310 | return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
311 | !!data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : false;
312 | }
313 | }
314 | }
315 | },
316 |
317 | args: function (selector, eventName) {
318 | var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].args
319 |
320 | if (!actualArgs) {
321 | throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
322 | }
323 |
324 | return actualArgs
325 | },
326 |
327 | wasTriggered: function (selector, eventName) {
328 | return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
329 | },
330 |
331 | wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) {
332 | var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
333 |
334 | if (Object.prototype.toString.call(expectedArgs) !== '[object Array]')
335 | actualArgs = actualArgs[0]
336 |
337 | return util.equals(actualArgs, expectedArgs, customEqualityTesters)
338 | },
339 |
340 | wasPrevented: function (selector, eventName) {
341 | var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
342 | , args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
343 | , e = args ? args[0] : undefined
344 |
345 | return e && e.isDefaultPrevented()
346 | },
347 |
348 | wasStopped: function (selector, eventName) {
349 | var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
350 | , args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
351 | , e = args ? args[0] : undefined
352 |
353 | return e && e.isPropagationStopped()
354 | },
355 |
356 | cleanUp: function () {
357 | data.spiedEvents = {}
358 | data.handlers = []
359 | }
360 | }
361 |
362 | var hasProperty = function (actualValue, expectedValue) {
363 | if (expectedValue === undefined)
364 | return actualValue !== undefined
365 |
366 | return actualValue === expectedValue
367 | }
368 |
369 | beforeEach(function () {
370 | jasmine.addMatchers({
371 | toHaveClass: function () {
372 | return {
373 | compare: function (actual, className) {
374 | return { pass: $(actual).hasClass(className) }
375 | }
376 | }
377 | },
378 |
379 | toHaveCss: function () {
380 | return {
381 | compare: function (actual, css) {
382 | for (var prop in css){
383 | var value = css[prop]
384 | // see issue #147 on gh
385 | ;if (value === 'auto' && $(actual).get(0).style[prop] === 'auto') continue
386 | if ($(actual).css(prop) !== value) return { pass: false }
387 | }
388 | return { pass: true }
389 | }
390 | }
391 | },
392 |
393 | toBeVisible: function () {
394 | return {
395 | compare: function (actual) {
396 | return { pass: $(actual).is(':visible') }
397 | }
398 | }
399 | },
400 |
401 | toBeHidden: function () {
402 | return {
403 | compare: function (actual) {
404 | return { pass: $(actual).is(':hidden') }
405 | }
406 | }
407 | },
408 |
409 | toBeSelected: function () {
410 | return {
411 | compare: function (actual) {
412 | return { pass: $(actual).is(':selected') }
413 | }
414 | }
415 | },
416 |
417 | toBeChecked: function () {
418 | return {
419 | compare: function (actual) {
420 | return { pass: $(actual).is(':checked') }
421 | }
422 | }
423 | },
424 |
425 | toBeEmpty: function () {
426 | return {
427 | compare: function (actual) {
428 | return { pass: $(actual).is(':empty') }
429 | }
430 | }
431 | },
432 |
433 | toBeInDOM: function () {
434 | return {
435 | compare: function (actual) {
436 | return { pass: $.contains(document.documentElement, $(actual)[0]) }
437 | }
438 | }
439 | },
440 |
441 | toExist: function () {
442 | return {
443 | compare: function (actual) {
444 | return { pass: $(actual).length }
445 | }
446 | }
447 | },
448 |
449 | toHaveLength: function () {
450 | return {
451 | compare: function (actual, length) {
452 | return { pass: $(actual).length === length }
453 | }
454 | }
455 | },
456 |
457 | toHaveAttr: function () {
458 | return {
459 | compare: function (actual, attributeName, expectedAttributeValue) {
460 | return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) }
461 | }
462 | }
463 | },
464 |
465 | toHaveProp: function () {
466 | return {
467 | compare: function (actual, propertyName, expectedPropertyValue) {
468 | return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) }
469 | }
470 | }
471 | },
472 |
473 | toHaveId: function () {
474 | return {
475 | compare: function (actual, id) {
476 | return { pass: $(actual).attr('id') == id }
477 | }
478 | }
479 | },
480 |
481 | toHaveHtml: function () {
482 | return {
483 | compare: function (actual, html) {
484 | return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) }
485 | }
486 | }
487 | },
488 |
489 | toContainHtml: function () {
490 | return {
491 | compare: function (actual, html) {
492 | var actualHtml = $(actual).html()
493 | , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
494 |
495 | return { pass: (actualHtml.indexOf(expectedHtml) >= 0) }
496 | }
497 | }
498 | },
499 |
500 | toHaveText: function () {
501 | return {
502 | compare: function (actual, text) {
503 | var actualText = $(actual).text()
504 | var trimmedText = $.trim(actualText)
505 |
506 | if (text && $.isFunction(text.test)) {
507 | return { pass: text.test(actualText) || text.test(trimmedText) }
508 | } else {
509 | return { pass: (actualText == text || trimmedText == text) }
510 | }
511 | }
512 | }
513 | },
514 |
515 | toContainText: function () {
516 | return {
517 | compare: function (actual, text) {
518 | var trimmedText = $.trim($(actual).text())
519 |
520 | if (text && $.isFunction(text.test)) {
521 | return { pass: text.test(trimmedText) }
522 | } else {
523 | return { pass: trimmedText.indexOf(text) != -1 }
524 | }
525 | }
526 | }
527 | },
528 |
529 | toHaveValue: function () {
530 | return {
531 | compare: function (actual, value) {
532 | return { pass: $(actual).val() === value }
533 | }
534 | }
535 | },
536 |
537 | toHaveData: function () {
538 | return {
539 | compare: function (actual, key, expectedValue) {
540 | return { pass: hasProperty($(actual).data(key), expectedValue) }
541 | }
542 | }
543 | },
544 |
545 | toContainElement: function () {
546 | return {
547 | compare: function (actual, selector) {
548 | return { pass: $(actual).find(selector).length }
549 | }
550 | }
551 | },
552 |
553 | toBeMatchedBy: function () {
554 | return {
555 | compare: function (actual, selector) {
556 | return { pass: $(actual).filter(selector).length }
557 | }
558 | }
559 | },
560 |
561 | toBeDisabled: function () {
562 | return {
563 | compare: function (actual, selector) {
564 | return { pass: $(actual).is(':disabled') }
565 | }
566 | }
567 | },
568 |
569 | toBeFocused: function (selector) {
570 | return {
571 | compare: function (actual, selector) {
572 | return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement }
573 | }
574 | }
575 | },
576 |
577 | toHandle: function () {
578 | return {
579 | compare: function (actual, event) {
580 | if ( !actual || actual.length === 0 ) return { pass: false };
581 | var events = $._data($(actual).get(0), "events")
582 |
583 | if (!events || !event || typeof event !== "string") {
584 | return { pass: false }
585 | }
586 |
587 | var namespaces = event.split(".")
588 | , eventType = namespaces.shift()
589 | , sortedNamespaces = namespaces.slice(0).sort()
590 | , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
591 |
592 | if (events[eventType] && namespaces.length) {
593 | for (var i = 0; i < events[eventType].length; i++) {
594 | var namespace = events[eventType][i].namespace
595 |
596 | if (namespaceRegExp.test(namespace))
597 | return { pass: true }
598 | }
599 | } else {
600 | return { pass: (events[eventType] && events[eventType].length > 0) }
601 | }
602 |
603 | return { pass: false }
604 | }
605 | }
606 | },
607 |
608 | toHandleWith: function () {
609 | return {
610 | compare: function (actual, eventName, eventHandler) {
611 | if ( !actual || actual.length === 0 ) return { pass: false };
612 | var normalizedEventName = eventName.split('.')[0]
613 | , stack = $._data($(actual).get(0), "events")[normalizedEventName]
614 |
615 | for (var i = 0; i < stack.length; i++) {
616 | if (stack[i].handler == eventHandler) return { pass: true }
617 | }
618 |
619 | return { pass: false }
620 | }
621 | }
622 | },
623 |
624 | toHaveBeenTriggeredOn: function () {
625 | return {
626 | compare: function (actual, selector) {
627 | var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) }
628 |
629 | result.message = result.pass ?
630 | "Expected event " + $(actual) + " not to have been triggered on " + selector :
631 | "Expected event " + $(actual) + " to have been triggered on " + selector
632 |
633 | return result;
634 | }
635 | }
636 | },
637 |
638 | toHaveBeenTriggered: function (){
639 | return {
640 | compare: function (actual) {
641 | var eventName = actual.eventName
642 | , selector = actual.selector
643 | , result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) }
644 |
645 | result.message = result.pass ?
646 | "Expected event " + eventName + " not to have been triggered on " + selector :
647 | "Expected event " + eventName + " to have been triggered on " + selector
648 |
649 | return result
650 | }
651 | }
652 | },
653 |
654 | toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) {
655 | return {
656 | compare: function (actual, selector, expectedArgs) {
657 | var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual)
658 | , result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) }
659 |
660 | if (wasTriggered) {
661 | var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1]
662 | result.message = result.pass ?
663 | "Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) :
664 | "Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
665 |
666 | } else {
667 | // todo check on this
668 | result.message = result.pass ?
669 | "Expected event " + actual + " not to have been triggered on " + selector :
670 | "Expected event " + actual + " to have been triggered on " + selector
671 | }
672 |
673 | return result
674 | }
675 | }
676 | },
677 |
678 | toHaveBeenPreventedOn: function () {
679 | return {
680 | compare: function (actual, selector) {
681 | var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) }
682 |
683 | result.message = result.pass ?
684 | "Expected event " + actual + " not to have been prevented on " + selector :
685 | "Expected event " + actual + " to have been prevented on " + selector
686 |
687 | return result
688 | }
689 | }
690 | },
691 |
692 | toHaveBeenPrevented: function () {
693 | return {
694 | compare: function (actual) {
695 | var eventName = actual.eventName
696 | , selector = actual.selector
697 | , result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) }
698 |
699 | result.message = result.pass ?
700 | "Expected event " + eventName + " not to have been prevented on " + selector :
701 | "Expected event " + eventName + " to have been prevented on " + selector
702 |
703 | return result
704 | }
705 | }
706 | },
707 |
708 | toHaveBeenStoppedOn: function () {
709 | return {
710 | compare: function (actual, selector) {
711 | var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) }
712 |
713 | result.message = result.pass ?
714 | "Expected event " + actual + " not to have been stopped on " + selector :
715 | "Expected event " + actual + " to have been stopped on " + selector
716 |
717 | return result;
718 | }
719 | }
720 | },
721 |
722 | toHaveBeenStopped: function () {
723 | return {
724 | compare: function (actual) {
725 | var eventName = actual.eventName
726 | , selector = actual.selector
727 | , result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) }
728 |
729 | result.message = result.pass ?
730 | "Expected event " + eventName + " not to have been stopped on " + selector :
731 | "Expected event " + eventName + " to have been stopped on " + selector
732 |
733 | return result
734 | }
735 | }
736 | }
737 | })
738 |
739 | jasmine.getEnv().addCustomEqualityTester(function(a, b) {
740 | if (a && b) {
741 | if (a instanceof $ || jasmine.isDomNode(a)) {
742 | var $a = $(a)
743 |
744 | if (b instanceof $)
745 | return $a.length == b.length && a.is(b)
746 |
747 | return $a.is(b);
748 | }
749 |
750 | if (b instanceof $ || jasmine.isDomNode(b)) {
751 | var $b = $(b)
752 |
753 | if (a instanceof $)
754 | return a.length == $b.length && $b.is(a)
755 |
756 | return $(b).is(a);
757 | }
758 | }
759 | })
760 |
761 | jasmine.getEnv().addCustomEqualityTester(function (a, b) {
762 | if (a instanceof $ && b instanceof $ && a.size() == b.size())
763 | return a.is(b)
764 | })
765 | })
766 |
767 | afterEach(function () {
768 | jasmine.getFixtures().cleanUp()
769 | jasmine.getStyleFixtures().cleanUp()
770 | jasmine.jQuery.events.cleanUp()
771 | })
772 |
773 | window.readFixtures = function () {
774 | return jasmine.getFixtures().proxyCallTo_('read', arguments)
775 | }
776 |
777 | window.preloadFixtures = function () {
778 | jasmine.getFixtures().proxyCallTo_('preload', arguments)
779 | }
780 |
781 | window.loadFixtures = function () {
782 | jasmine.getFixtures().proxyCallTo_('load', arguments)
783 | }
784 |
785 | window.appendLoadFixtures = function () {
786 | jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
787 | }
788 |
789 | window.setFixtures = function (html) {
790 | return jasmine.getFixtures().proxyCallTo_('set', arguments)
791 | }
792 |
793 | window.appendSetFixtures = function () {
794 | jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
795 | }
796 |
797 | window.sandbox = function (attributes) {
798 | return jasmine.getFixtures().sandbox(attributes)
799 | }
800 |
801 | window.spyOnEvent = function (selector, eventName) {
802 | return jasmine.jQuery.events.spyOn(selector, eventName)
803 | }
804 |
805 | window.preloadStyleFixtures = function () {
806 | jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
807 | }
808 |
809 | window.loadStyleFixtures = function () {
810 | jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
811 | }
812 |
813 | window.appendLoadStyleFixtures = function () {
814 | jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
815 | }
816 |
817 | window.setStyleFixtures = function (html) {
818 | jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
819 | }
820 |
821 | window.appendSetStyleFixtures = function (html) {
822 | jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
823 | }
824 |
825 | window.loadJSONFixtures = function () {
826 | return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
827 | }
828 |
829 | window.getJSONFixture = function (url) {
830 | return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
831 | }
832 | }(window, window.jasmine, window.jQuery);
833 |
--------------------------------------------------------------------------------